01da53e10f38db616d9c841de8c8a8a31bf60d1c
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #2828 from r3dDoX/master
removed a hardcoded 'origin' in git.zsh and added new function for number of commits ahead of remote
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index b0e73bf3ab5dabbfb0654b06c4c8f2c4bfbc2a16..7aa5a0ea2fe8f928681efdb3857af10587c3abc3 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -54,11 +54,19 @@ git_remote_status() {
6
7 # Checks if there are commits ahead from remote
8 function git_prompt_ahead() {
9- if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
10+ if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
11 echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
12 fi
13 }
14
15+# Gets the number of commits ahead from remote
16+function git_commits_ahead() {
17+ if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
18+ COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
19+ echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
20+ fi
21+}
22+
23 # Formats prompt string for current git commit short SHA
24 function git_prompt_short_sha() {
25 SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"