From 532c90742dbe810569c97ad5ceeb20d4f8353918 Mon Sep 17 00:00:00 2001 From: Heiko Heijenga Date: Wed, 17 Sep 2014 20:37:10 -0700 Subject: [PATCH] Added support to show nr of stashes --- gitstatus.py | 2 ++ zshrc.sh | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gitstatus.py b/gitstatus.py index d14420eb..2d26352f 100755 --- a/gitstatus.py +++ b/gitstatus.py @@ -44,6 +44,7 @@ remote_ref = merge_name else: remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) + stashlist = Popen(['git', 'stash', 'list'],stdout=PIPE, stderr=PIPE).communicate()[0].decode("utf-8").splitlines() revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) revlist = revgit.communicate()[0] if revgit.poll(): # fallback to local @@ -60,6 +61,7 @@ conflicts, changed, untracked, + str(len(stashlist)) ]) print(out) diff --git a/zshrc.sh b/zshrc.sh index a1386348..13f367a2 100644 --- a/zshrc.sh +++ b/zshrc.sh @@ -51,6 +51,7 @@ function update_current_git_vars() { GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] GIT_CHANGED=$__CURRENT_GIT_STATUS[6] GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] + GIT_STASHES=$__CURRENT_GIT_STATUS[8] } @@ -80,7 +81,10 @@ git_super_status() { if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" fi - STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" + if [ "$GIT_STASHES" -ne "0" ]; then + STATUS="$STATUS $ZSH_THEME_GIT_PROMPT_STASHES$GIT_STASHES%{${reset_color}%}" + fi + STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" echo "$STATUS" fi } @@ -97,5 +101,6 @@ ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" +ZSH_THEME_GIT_PROMPT_STASHES="%{$fg_bold[yellow]%}%{⚑%G%}"