Skip to content

Commit 367f089

Browse files
committed
Merge branch 'fc/completion-colors-do-not-need-prompt-command' into seen
* fc/completion-colors-do-not-need-prompt-command: completion: prompt: use generic colors
2 parents a94a9e5 + 7ee1af8 commit 367f089

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

contrib/completion/git-prompt.sh

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@
100100
#
101101
# If you would like a colored hint about the current dirty state, set
102102
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
103-
# the colored output of "git status -sb" and are available only when
104-
# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
105-
# but always available in Zsh.
103+
# the colored output of "git status -sb".
106104
#
107105
# If you would like __git_ps1 to do nothing in the case when the current
108106
# directory is set up to be ignored by git, then set
@@ -259,12 +257,12 @@ __git_ps1_colorize_gitstring ()
259257
local c_lblue='%F{blue}'
260258
local c_clear='%f'
261259
else
262-
# Using \[ and \] around colors is necessary to prevent
260+
# Using \001 and \002 around colors is necessary to prevent
263261
# issues with command line editing/browsing/completion!
264-
local c_red='\[\e[31m\]'
265-
local c_green='\[\e[32m\]'
266-
local c_lblue='\[\e[1;34m\]'
267-
local c_clear='\[\e[0m\]'
262+
local c_red=$'\001\e[31m\002'
263+
local c_green=$'\001\e[32m\002'
264+
local c_lblue=$'\001\e[1;34m\002'
265+
local c_clear=$'\001\e[0m\002'
268266
fi
269267
local bad_color=$c_red
270268
local ok_color=$c_green
@@ -574,11 +572,8 @@ __git_ps1 ()
574572
b="\${__git_ps1_branch_name}"
575573
fi
576574

577-
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
578575
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
579-
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
580-
__git_ps1_colorize_gitstring
581-
fi
576+
__git_ps1_colorize_gitstring
582577
fi
583578

584579
local f="$h$w$i$s$u$p"

t/t9903-bash-prompt.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1313
. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
1414

1515
actual="$TRASH_DIRECTORY/actual"
16-
c_red='\\[\\e[31m\\]'
17-
c_green='\\[\\e[32m\\]'
18-
c_lblue='\\[\\e[1;34m\\]'
19-
c_clear='\\[\\e[0m\\]'
16+
c_red='\001\e[31m\002'
17+
c_green='\001\e[32m\002'
18+
c_lblue='\001\e[1;34m\002'
19+
c_clear='\001\e[0m\002'
2020

2121
test_expect_success 'setup for prompt tests' '
2222
git init otherrepo &&

0 commit comments

Comments
 (0)