Skip to content

Commit

Permalink
Add git_prompt_behind functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
scelis committed Sep 11, 2012
1 parent 3482cd5 commit 901cfde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/git.zsh
@@ -1,7 +1,7 @@
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_ahead)$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_ahead)$(git_prompt_behind)$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}


Expand All @@ -26,6 +26,13 @@ function git_prompt_ahead() {
fi
}

# Checks if there are commits behind from remote
function git_prompt_behind() {
if $(echo "$(git log HEAD..origin/$(current_branch) 2> /dev/null)" | grep '^commit' &> /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"
Expand Down
1 change: 1 addition & 0 deletions themes/scelis.zsh-theme
Expand Up @@ -5,3 +5,4 @@ ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_AHEAD=""
ZSH_THEME_GIT_PROMPT_BEHIND=""

0 comments on commit 901cfde

Please sign in to comment.