add git stash indicator into git prompt

This commit is contained in:
Godwin Ko 2011-10-12 12:05:33 +08:00
commit c26323abd4
2 changed files with 12 additions and 1 deletions

View file

@ -1,7 +1,7 @@
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(parse_git_stash)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
# Checks if working tree is dirty
@ -13,6 +13,15 @@ parse_git_dirty() {
fi
}
# Checks if working tree has stash
parse_git_stash() {
if [[ -n $(git stash list 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_STASH"
else
echo "$ZSH_THEME_GIT_PROMPT_NOSTASH"
fi
}
# Checks if there are commits ahead from remote
function git_prompt_ahead() {
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then