From e4b64448facdc619f2063cfa9888cbb25f13a8bf Mon Sep 17 00:00:00 2001 From: Shawn LeMaster Date: Sun, 8 Nov 2020 23:08:24 -0600 Subject: [PATCH] Don't assume $__fish_git_prompt_char_cleanstate is non-empty This fixes the case where an empty "clean state" character can cause a spurious space character at the end of the git prompt. --- share/functions/fish_git_prompt.fish | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index 1b9bb19d9..1da324fef 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -403,7 +403,10 @@ function fish_git_prompt --description "Prompt function for Git" and test "$dirty" != false and test "$untracked" != false end - set informative_status "$space"(__fish_git_prompt_informative_status $git_dir) + set informative_status (__fish_git_prompt_informative_status $git_dir) + if test -n "$informative_status" + set informative_status "$space$informative_status" + end else # This has to be set explicitly. if test "$dirty" = true @@ -533,7 +536,9 @@ function __fish_git_prompt_informative_status set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles + $stashstate 2>/dev/null) if test -z "$state" or test "$state" = 0 - set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done + if test -n "$___fish_git_prompt_char_cleanstate" + set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done + end else for i in $___fish_git_prompt_status_order if [ $$i != 0 ]