]> git.ipfire.org Git - thirdparty/git.git/commit
git-prompt: support custom 0-width PS1 markers
authorAvi Halachmi (:avih) <avihpit@yahoo.com>
Tue, 20 Aug 2024 01:48:32 +0000 (01:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Aug 2024 15:28:19 +0000 (08:28 -0700)
commitfbcdfab34852329929e6bfdd2bac8e49f2e3d8e3
treea9d8150f9d39b70ee4129d4ee96753c0992894e2
parent0dbe3d3f1610742f118237f2ad8a9e91bb3cdd39
git-prompt: support custom 0-width PS1 markers

When using colors, the shell needs to identify 0-width substrings
in PS1 - such as color escape sequences - when calculating the
on-screen width of the prompt.

Until now, we used the form %F{<color>} in zsh - which it knows is
0-width, or otherwise use standard SGR esc sequences wrapped between
byte values 1 and 2 (SOH, STX) as 0-width start/end markers, which
bash/readline identify as such.

But now that more shells are supported, the standard SGR sequences
typically work, but the SOH/STX markers might not be identified.

This commit adds support for vars GIT_PS1_COLOR_{PRE,POST} which
set custom 0-width markers or disable the markers.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-prompt.sh