From 47d96cda201737c75a488605c188e68300a3f545 Mon Sep 17 00:00:00 2001 From: mitchell Date: Sat, 8 Feb 2020 17:45:16 -0500 Subject: [PATCH] Change the way git branch detected to support older versions --- .config/fish/functions/fish_prompt.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish index 46174d0..2e11e93 100644 --- a/.config/fish/functions/fish_prompt.fish +++ b/.config/fish/functions/fish_prompt.fish @@ -72,8 +72,8 @@ function fish_prompt --description 'Write out the prompt' set branch_color yellow end - set -l cur_branch (git branch --show-current) - if test -z $cur_branch; set cur_branch 'detached'; end + set -l cur_branch (string sub -s 3 (string match -r '^\* .*$' (git branch))) + if string match -q '(HEAD detached*' $cur_branch; set cur_branch 'detached'; end set -l cur_branch_len (string length $cur_branch) if test $cur_branch_len -gt 21