From 37a0679dda8c5a551213825bd919e4c732532190 Mon Sep 17 00:00:00 2001
From: Justin Hileman <justin@justinhileman.info>
Date: Sun, 23 Nov 2014 10:20:54 -0800
Subject: [PATCH] [bobthefish] much cleaner git "ahead" flag.

---
 themes/bobthefish/fish_prompt.fish | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/themes/bobthefish/fish_prompt.fish b/themes/bobthefish/fish_prompt.fish
index c555ab7..b4315c1 100644
--- a/themes/bobthefish/fish_prompt.fish
+++ b/themes/bobthefish/fish_prompt.fish
@@ -267,12 +267,11 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
   end
 end
 
-# TODO: clean up the fugly $ahead business
 function __bobthefish_prompt_git -d 'Display the actual git state'
   set -l dirty   (command git diff --no-ext-diff --quiet --exit-code; or echo -n '*')
   set -l staged  (command git diff --cached --no-ext-diff --quiet --exit-code; or echo -n '~')
   set -l stashed (command git rev-parse --verify refs/stash > /dev/null 2>&1; and echo -n '$')
-  set -l ahead   (command git branch -v 2> /dev/null | grep -Eo '^\* [^ ]* *[^ ]* *\[[^]]*\]' | grep -Eo '\[[^]]*\]$' | awk 'ORS="";/ahead/ {print "+"} /behind/ {print "-"}' | sed -e 's/+-/±/')
+  set -l ahead   (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null | awk '/>/ {a += 1} /</ {b += 1} {if (a > 0) nextfile} END {if (a > 0 && b > 0) print "±"; else if (a > 0) print "+"; else if (b > 0) print "-"}')
 
   set -l new (command git ls-files --other --exclude-standard);
   test "$new"; and set new '…'
-- 
GitLab