From 354c6b1b6708cedd4b37a75df174bb6558faadf4 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 26 Jan 2019 13:33:15 +0100 Subject: [PATCH] git_prompt: Read "bash.showInformativeStatus" git config variable This allows disabling _just_ the informative status. We still also use the dirty and untracked variables, but only if informative status hasn't explicitly been enabled. --- share/functions/__fish_git_prompt.fish | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index f039162c5..d835e759b 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -376,6 +376,8 @@ function __fish_git_prompt --description "Prompt function for Git" # That means if neither is set, this stays empty. # # So "!= true" or "!= false" are useful tests if you want to do something by default. + set -l informative (command git config --bool bash.showInformativeStatus) + set -l dirty (command git config --bool bash.showDirtyState) if not set -q dirty[1] set -q __fish_git_prompt_showdirtystate @@ -389,12 +391,16 @@ function __fish_git_prompt --description "Prompt function for Git" end if test "true" = $inside_worktree - # Use informative status, unless dirty or untracked have been set to false. + # Use informative status if it has been enabled locally, or it has been + # enabled globally (via the fish variable) and dirty or untracked are not false. # # This is to allow overrides for the repository. - if set -q __fish_git_prompt_show_informative_status - and test "$dirty" != false - and test "$untracked" != false + if test "$informative" = true + or begin + set -q __fish_git_prompt_show_informative_status + and test "$dirty" != false + and test "$untracked" != false + end set informative_status "$space"(__fish_git_prompt_informative_status) else # This has to be set explicitly.