From 19bcf9fc36a72c319cb0fc8e30f3207f59dbb7c8 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 11 Nov 2018 14:06:05 +0100 Subject: [PATCH] sample_prompts/acidhub: Clean - Remove useless helper functions - Remove `sed` call - Cut down on `git` calls The status display still needs a bit of work. --- share/tools/web_config/sample_prompts/acidhub.fish | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/share/tools/web_config/sample_prompts/acidhub.fish b/share/tools/web_config/sample_prompts/acidhub.fish index 6d00ef901..dfba6eace 100644 --- a/share/tools/web_config/sample_prompts/acidhub.fish +++ b/share/tools/web_config/sample_prompts/acidhub.fish @@ -3,15 +3,10 @@ function fish_prompt -d "Write out the prompt" set laststatus $status - function _git_branch_name - echo (git symbolic-ref HEAD 2>/dev/null | sed -e 's|^refs/heads/||') - end - function _is_git_dirty - echo (git status -s --ignore-submodules=dirty 2>/dev/null) - end - if [ (_git_branch_name) ] - set -l git_branch (set_color -o blue)(_git_branch_name) - if [ (_is_git_dirty) ] + + if set -l git_branch (command git symbolic-ref HEAD 2>/dev/null | string replace refs/heads/ '') + set git_branch (set_color -o blue)"$git_branch" + if command git diff-index --quiet HEAD -- for i in (git branch -qv --no-color | string match -r '\*' | cut -d' ' -f4- | cut -d] -f1 | tr , \n)\ (git status --porcelain | cut -c 1-2 | uniq) switch $i @@ -38,6 +33,7 @@ function fish_prompt -d "Write out the prompt" end set git_info "(git$git_status$git_branch"(set_color white)")" end + set_color -b black printf '%s%s%s%s%s%s%s%s%s%s%s%s%s' (set_color -o white) '❰' (set_color green) $USER (set_color white) '❙' (set_color yellow) (echo $PWD | sed -e "s|^$HOME|~|") (set_color white) $git_info (set_color white) '❱' (set_color white) if test $laststatus -eq 0