Display a yellow + if stashs
Add a yellow + after the git infos, if there is at least one stash. The * in case of untracked file is now red.
This commit is contained in:
parent
e2b51ef3da
commit
b776cd8e64
@ -61,7 +61,8 @@ to date, in red if there is changes, in yellow if there is pending
|
||||
commits to push;
|
||||
* the number of added/deleted lines (git) or files (fossil), if
|
||||
changes have been made and the number of pending commits, if any;
|
||||
* a star if there is some untracked files in the repository;
|
||||
* a yellow plus if there is stashed modifications;
|
||||
* a red 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 fossil, $ for simple user, a red # for root.
|
||||
@ -259,6 +260,7 @@ Special characters:
|
||||
* `LP_MARK_GIT` (default: "±") prompt mark in git repositories
|
||||
* `LP_MARK_FOSSIL` (default: "⌘") prompt mark in fossil repositories
|
||||
* `LP_MARK_UNTRACKED` (default: "*") if git has untracked files
|
||||
* `LP_MARK_STASH` (default: "+") if git has stashed modifications
|
||||
* `LP_TITLE_OPEN` (default: "\e]0;") escape character opening a window's title
|
||||
* `LP_TITLE_CLOSE` (default: "\a") escape character closing a window's title
|
||||
|
||||
|
@ -19,6 +19,7 @@ if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]
|
||||
LP_MARK_GIT="±" # prompt mark in git repositories
|
||||
LP_MARK_FOSSIL="⌘" # prompt mark in fossil repositories
|
||||
LP_MARK_UNTRACKED="*" # if git has untracked files
|
||||
LP_MARK_STASH="+" # if git has stashs
|
||||
else
|
||||
# If charset is anything else, fallback to ASCII chars
|
||||
LP_MARK_BATTERY="b"
|
||||
@ -30,6 +31,7 @@ else
|
||||
LP_MARK_GIT="+"
|
||||
LP_MARK_FOSSIL="f"
|
||||
LP_MARK_UNTRACKED="*"
|
||||
LP_MARK_STASH="+"
|
||||
fi
|
||||
|
||||
# Do not prefix the prompt
|
||||
|
19
liquidprompt
19
liquidprompt
@ -218,6 +218,7 @@ _lp_source_config()
|
||||
LP_MARK_GIT=${LP_MARK_GIT:-"±"}
|
||||
LP_MARK_FOSSIL=${LP_MARK_FOSSIL:-"⌘"}
|
||||
LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"}
|
||||
LP_MARK_STASH=${LP_MARK_STASH:-"+"}
|
||||
|
||||
LP_COLOR_PATH=${LP_COLOR_PATH:-$BOLD_WHITE}
|
||||
LP_COLOR_PATH_ROOT=${LP_COLOR_PATH_ROOT:-$BOLD_YELLOW}
|
||||
@ -655,14 +656,20 @@ _lp_git_branch_color()
|
||||
git diff --cached --quiet >/dev/null 2>&1
|
||||
GDC=$?
|
||||
|
||||
local has_untracked
|
||||
has_untracked=$(git status 2>/dev/null | grep '\(# Untracked\)')
|
||||
local has_untracked=$(git status 2>/dev/null | grep '\(# Untracked\)')
|
||||
if [[ -z "$has_untracked" ]] ; then
|
||||
has_untracked=""
|
||||
else
|
||||
has_untracked="$LP_MARK_UNTRACKED"
|
||||
fi
|
||||
|
||||
local has_stash=$(git stash list 2>/dev/null)
|
||||
if [[ -z "$has_stash" ]] ; then
|
||||
has_stash=""
|
||||
else
|
||||
has_stash="$LP_MARK_STASH"
|
||||
fi
|
||||
|
||||
local has_commit
|
||||
has_commit=$(git rev-list --no-merges --count origin/${branch}..${branch} 2>/dev/null)
|
||||
if [[ -z "$has_commit" ]] ; then
|
||||
@ -673,16 +680,16 @@ _lp_git_branch_color()
|
||||
has_lines=$(git diff --numstat 2>/dev/null | 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}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})${LP_COLOR_CHANGES}${has_untracked}${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_COMMITS}${has_stash}${LP_COLOR_CHANGES}${has_untracked}${NO_COL}"
|
||||
else
|
||||
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})${LP_COLOR_CHANGES}${has_untracked}${NO_COL}" # changes to commit
|
||||
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})${LP_COLOR_COMMITS}${has_stash}${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}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})${LP_COLOR_COMMITS}${has_untracked}${NO_COL}"
|
||||
ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})${LP_COLOR_COMMITS}${LP_COLOR_COMMITS}${has_stash}${LP_COLOR_CHANGES}${has_untracked}${NO_COL}"
|
||||
else
|
||||
ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}" # nothing to commit or push
|
||||
ret="${LP_COLOR_UP}${branch}${LP_COLOR_COMMITS}${has_stash}${LP_COLOR_CHANGES}${has_untracked}${NO_COL}" # nothing to commit or push
|
||||
fi
|
||||
fi
|
||||
echo -ne "$ret"
|
||||
|
Loading…
x
Reference in New Issue
Block a user