summaryrefslogtreecommitdiff
path: root/lib/git.zsh
diff options
context:
space:
mode:
authorleif.hanack <strug@web.de>2014-06-04 00:37:33 +0200
committerncanceill <nicolas.canceill@ens-cachan.org>2015-06-10 14:36:54 +0200
commit70c4a27fd6048c3213dd2f3bae21bff26005bc16 (patch)
tree38630e394da024b7ba4a85c8d7d8c8bba8c01778 /lib/git.zsh
parent41104f8af842cd9ba441255808053a36ef4fcd6b (diff)
downloadzsh-70c4a27fd6048c3213dd2f3bae21bff26005bc16.tar.gz
zsh-70c4a27fd6048c3213dd2f3bae21bff26005bc16.tar.bz2
zsh-70c4a27fd6048c3213dd2f3bae21bff26005bc16.zip
Added a possibility to display the remote branch and the number of commits you are ahead or behind
Diffstat (limited to 'lib/git.zsh')
-rw-r--r--lib/git.zsh20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/git.zsh b/lib/git.zsh
index 118841f06..733492ba0 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -36,16 +36,26 @@ git_remote_status() {
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
- if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
+ if [ $ahead -gt 0 ] && [ $behind -eq 0 ]
then
- echo "$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
- elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
+ git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
+ git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
+ elif [ $behind -gt 0 ] && [ $ahead -eq 0 ]
then
- echo "$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
+ git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
+ git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
then
- echo "$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
+ git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
+ git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
fi
+
+ if [ $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]
+ then
+ git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
+ fi
+
+ echo $git_remote_status
fi
}