From a9617f97b6e6b635709d512278118aa51b31d368 Mon Sep 17 00:00:00 2001 From: Twinkle Date: Fri, 17 Feb 2017 13:21:12 +0800 Subject: [PATCH] enhance git repo for Robbyrussell prompt --- share/tools/web_config/sample_prompts/robbyrussell.fish | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/tools/web_config/sample_prompts/robbyrussell.fish b/share/tools/web_config/sample_prompts/robbyrussell.fish index 1e94127f9..849273a22 100644 --- a/share/tools/web_config/sample_prompts/robbyrussell.fish +++ b/share/tools/web_config/sample_prompts/robbyrussell.fish @@ -6,7 +6,12 @@ function fish_prompt if not set -q -g __fish_robbyrussell_functions_defined set -g __fish_robbyrussell_functions_defined function _git_branch_name - echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') + set -l branch (git symbolic-ref --quiet HEAD ^/dev/null) + if set -q branch[1] + echo (string replace -r '^refs/heads/' '' $branch) + else + echo (git rev-parse --short HEAD ^/dev/null) + end end function _is_git_dirty