akhayyat theme: git info: detect ahead and behind in one shot

This commit is contained in:
Ahmad Khayyat 2012-09-09 15:39:43 -04:00
parent 342a011541
commit cb5e8c2b1a

View file

@ -89,13 +89,14 @@ function +vi-git-untracked {
}
function +vi-git-st() {
local ahead behind
local ahead behind ahead_and_behind
local -a gitstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "%F{yellow}↑%f" )
ahead_and_behind=$(git rev-list --count --left-right HEAD...@{upstream} 2>/dev/null)
ahead=$ahead_and_behind[(w)1]
behind=$ahead_and_behind[(w)2]
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "%F{yellow}↑%f" )
(( $behind )) && gitstatus+=( "%F{$orange}↓%f" )
hook_com[misc]+=${(j:/:)gitstatus}