]> git.ipfire.org Git - thirdparty/git.git/blobdiff - contrib/completion/git-prompt.sh
Merge branch 'mt/do-not-use-scld-in-working-tree'
[thirdparty/git.git] / contrib / completion / git-prompt.sh
index 16260bab73346ba79d8e96eda03628d7dbd4b75b..4640a1535d15968c0a16ce265d028282d43b0962 100644 (file)
@@ -97,7 +97,8 @@
 # If you would like a colored hint about the current dirty state, set
 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
 # the colored output of "git status -sb" and are available only when
-# using __git_ps1 for PROMPT_COMMAND or precmd.
+# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
+# but always available in Zsh.
 #
 # If you would like __git_ps1 to do nothing in the case when the current
 # directory is set up to be ignored by git, then set
@@ -137,6 +138,7 @@ __git_ps1_show_upstream ()
        done <<< "$output"
 
        # parse configuration values
+       local option
        for option in ${GIT_PS1_SHOWUPSTREAM}; do
                case "$option" in
                git|svn) upstream="$option" ;;
@@ -553,9 +555,11 @@ __git_ps1 ()
 
        local z="${GIT_PS1_STATESEPARATOR-" "}"
 
-       # NO color option unless in PROMPT_COMMAND mode
-       if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-               __git_ps1_colorize_gitstring
+       # NO color option unless in PROMPT_COMMAND mode or it's Zsh
+       if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+               if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+                       __git_ps1_colorize_gitstring
+               fi
        fi
 
        b=${b##refs/heads/}