59c8fcc712556a4c0b612898073e212877c21d60

Author
r3dDoX <patrick@walther-online.ch>
Committer
r3dDoX <patrick@walther-online.ch>
Date

Message

added new function to get number of commits ahead of remote

Diff

 1diff --git a/lib/git.zsh b/lib/git.zsh
 2index 3eca8a6c6aed44aaf6a7f08d397c367a69d6ccec..d6cee37c3cca5ffbdb1e5f72e0e3ea563c99ffb1 100644
 3--- a/lib/git.zsh
 4+++ b/lib/git.zsh
 5@@ -59,6 +59,13 @@ function git_prompt_ahead() {
 6   fi
 7 }
 8 
 9+# Gets the number of commits ahead from remote
10+function git_commits_ahead() {
11+  if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
12+    echo "$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')"
13+  fi
14+}
15+
16 # Formats prompt string for current git commit short SHA
17 function git_prompt_short_sha() {
18   SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"