add configurable untracked changes mark, at a better position
This commit is contained in:
parent
822b20eec6
commit
991b2b38be
@ -27,7 +27,7 @@ in a git repository on a server, at branch "myb":
|
||||
|
||||
A liquid prompt displaying everything may look like this:
|
||||
|
||||
`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ master(+10/-5,3) 125 ± `
|
||||
`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ master(+10/-5,3)* 125 ± `
|
||||
|
||||
It displays:
|
||||
|
||||
@ -57,6 +57,7 @@ preserving the first two directories;
|
||||
there is changes, in yellow if there is pending commits to push;
|
||||
* the number of added/deleted lines, if changes have been made and the number
|
||||
of pending commits, if any;
|
||||
* a star if there is some untracked files in the repository;
|
||||
* the error code of the last command, if it has failed in some way;
|
||||
* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, $ for simple
|
||||
user, a red # for root.
|
||||
|
@ -14,18 +14,20 @@ if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]
|
||||
LP_ADAPTER_MARK="⏚" # displayed when plugged
|
||||
LP_LOAD_MARK="⌂" # in front of the load
|
||||
LP_PROXY_MARK="↥" # indicate a proxy in use
|
||||
LP_GIT_MARK="±" # prompt mark in git repositories
|
||||
LP_MERCURIAL_MARK="☿" # prompt mark in hg repositories
|
||||
LP_SUBVERSION_MARK="‡" # prompt mark in svn repositories
|
||||
LP_GIT_MARK="±" # prompt mark in git repositories
|
||||
LP_UNTRACKED="*" # if git has untracked files
|
||||
else
|
||||
# If charset is anything else, fallback to ASCII chars
|
||||
LP_BATTERY_MARK="b"
|
||||
LP_ADAPTER_MARK="p"
|
||||
LP_LOAD_MARK="c"
|
||||
LP_PROXY_MARK="^"
|
||||
LP_GIT_MARK="+"
|
||||
LP_MERCURIAL_MARK="m"
|
||||
LP_SUBVERSION_MARK="="
|
||||
LP_GIT_MARK="+"
|
||||
LP_UNTRACKED="*"
|
||||
fi
|
||||
|
||||
# Colors
|
||||
|
11
liquidprompt
11
liquidprompt
@ -192,9 +192,10 @@ LP_BATTERY_MARK=${LP_BATTERY_MARK:-"⌁"}
|
||||
LP_ADAPTER_MARK=${LP_ADAPTER_MARK:-"⏚"}
|
||||
LP_LOAD_MARK=${LP_LOAD_MARK:-"⌂"}
|
||||
LP_PROXY_MARK=${LP_PROXY_MARK:-"↥"}
|
||||
LP_GIT_MARK=${LP_GIT_MARK:-"±"}
|
||||
LP_MERCURIAL_MARK=${LP_MERCURIAL_MARK:-"☿"}
|
||||
LP_SUBVERSION_MARK=${LP_SUBVERSION_MARK:-"‡"}
|
||||
LP_GIT_MARK=${LP_GIT_MARK:-"±"}
|
||||
LP_UNTRACKED=${LP_UNTRACKED:-"*"}
|
||||
|
||||
LP_ENABLE_GIT=${LP_ENABLE_GIT:-1}
|
||||
LP_ENABLE_SVN=${LP_ENABLE_SVN:-1}
|
||||
@ -561,7 +562,7 @@ _lp_git_branch_color()
|
||||
if [[ -z "$has_untracked" ]] ; then
|
||||
has_untracked=""
|
||||
else
|
||||
has_untracked="*"
|
||||
has_untracked="$LP_UNTRACKED"
|
||||
fi
|
||||
|
||||
local has_commit
|
||||
@ -574,14 +575,14 @@ _lp_git_branch_color()
|
||||
has_lines=$(git diff --numstat | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d/-%d\n", plus, minus)}')
|
||||
if [[ "$has_commit" -gt "0" ]] ; then
|
||||
# Changes to commit and commits to push
|
||||
ret="${LP_COLOR_CHANGES}${branch}${has_untracked}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})"
|
||||
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})${LP_COLOR_CHANGES}${has_untracked}${NO_COL}"
|
||||
else
|
||||
ret="${LP_COLOR_CHANGES}${branch}${has_untracked}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})" # changes to commit
|
||||
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})${LP_COLOR_CHANGES}${has_untracked}${NO_COL}" # changes to commit
|
||||
fi
|
||||
else
|
||||
if [[ "$has_commit" -gt "0" ]] ; then
|
||||
# some commit(s) to push
|
||||
ret="${LP_COLOR_COMMITS}${branch}${has_untracked}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})"
|
||||
ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})${LP_COLOR_COMMITS}${has_untracked}${NO_COL}"
|
||||
else
|
||||
ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}" # nothing to commit or push
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user