summaryrefslogtreecommitdiff
path: root/lib/git.zsh
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2014-07-15 07:38:55 -0700
committerRobby Russell <robby@planetargon.com>2014-07-15 07:38:55 -0700
commit01da53e10f38db616d9c841de8c8a8a31bf60d1c (patch)
tree834ff33519c0c31407438b290e631c2152b2c6d5 /lib/git.zsh
parent9f8c5d002135b020aed9c9a33415d24f45945f5e (diff)
parent514693125b12d4b4cd099dcb09174f7bfd9a5b0e (diff)
downloadzsh-01da53e10f38db616d9c841de8c8a8a31bf60d1c.tar.gz
zsh-01da53e10f38db616d9c841de8c8a8a31bf60d1c.tar.bz2
zsh-01da53e10f38db616d9c841de8c8a8a31bf60d1c.zip
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
Diffstat (limited to 'lib/git.zsh')
-rw-r--r--lib/git.zsh10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/git.zsh b/lib/git.zsh
index b0e73bf3a..7aa5a0ea2 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -54,11 +54,19 @@ git_remote_status() {
# Checks if there are commits ahead from remote
function git_prompt_ahead() {
- if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
+ if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}
+# Gets the number of commits ahead from remote
+function git_commits_ahead() {
+ if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
+ COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ')
+ echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
+ fi
+}
+
# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"