From cf9a16efad17a95334ebc731ebc2228ad05a0607 Mon Sep 17 00:00:00 2001 From: Michele Campeotto Date: Wed, 1 Aug 2012 14:47:55 -0700 Subject: [PATCH] added git_prompt_behind use status for git_prompt_ahead instead of log --- lib/git.zsh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index d2cdde037..0193d2775 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -28,11 +28,19 @@ function parse_git_dirty() { git_parse_dirty } # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(git status --porcelain --branch 2> /dev/null | grep '^## .*ahead' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } +# Checks if there are commits behind from remote +function git_prompt_behind() { + if $(git status --porcelain --branch 2> /dev/null | grep '^## .*behind' &> /dev/null); then + echo $ZSH_THEME_GIT_PROMPT_BEHIND + fi +} + + # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"