From cb5e8c2b1a087d4c820c0d8b6512c91cd3667dd7 Mon Sep 17 00:00:00 2001 From: Ahmad Khayyat Date: Sun, 9 Sep 2012 15:39:43 -0400 Subject: [PATCH] akhayyat theme: git info: detect ahead and behind in one shot --- modules/prompt/functions/prompt_akhayyat_setup | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/prompt/functions/prompt_akhayyat_setup b/modules/prompt/functions/prompt_akhayyat_setup index edba7eff..cb4eab70 100644 --- a/modules/prompt/functions/prompt_akhayyat_setup +++ b/modules/prompt/functions/prompt_akhayyat_setup @@ -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}