diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-03-28 10:51:52 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-03-28 10:51:52 -0700 |
commit | 6041a13ec2958b5c39a5f2bbadfffb4d4ce79d46 (patch) | |
tree | 0fe0b1a26c6d573775a28ad3073555fa41e2a6a9 /contrib | |
parent | 27d43aaaf50ef0ae014b88bba294f93658016a2e (diff) | |
parent | 7ee1af8cb8b97385fc4e603bc024d877def5adb4 (diff) | |
download | git-6041a13ec2958b5c39a5f2bbadfffb4d4ce79d46.tar.gz |
Merge branch 'fc/completion-colors-do-not-need-prompt-command'
Lift the limitation that colored prompts can only be used with
PROMPT_COMMAND mode.
* fc/completion-colors-do-not-need-prompt-command:
completion: prompt: use generic colors
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/completion/git-prompt.sh | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 57972c2845..76ee4ab1e5 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -100,9 +100,7 @@ # # 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 in Bash, -# but always available in Zsh. +# the colored output of "git status -sb". # # 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 @@ -259,12 +257,12 @@ __git_ps1_colorize_gitstring () local c_lblue='%F{blue}' local c_clear='%f' else - # Using \[ and \] around colors is necessary to prevent + # Using \001 and \002 around colors is necessary to prevent # issues with command line editing/browsing/completion! - local c_red='\[\e[31m\]' - local c_green='\[\e[32m\]' - local c_lblue='\[\e[1;34m\]' - local c_clear='\[\e[0m\]' + local c_red=$'\001\e[31m\002' + local c_green=$'\001\e[32m\002' + local c_lblue=$'\001\e[1;34m\002' + local c_clear=$'\001\e[0m\002' fi local bad_color=$c_red local ok_color=$c_green @@ -574,11 +572,8 @@ __git_ps1 () b="\${__git_ps1_branch_name}" fi - # 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 + __git_ps1_colorize_gitstring fi local f="$h$w$i$s$u$p" |