diff options
| author | Matt Hunter <m@lfurio.us> | 2026-05-19 00:12:42 -0400 |
|---|---|---|
| committer | Matt Hunter <m@lfurio.us> | 2026-05-26 02:12:36 -0400 |
| commit | 990756613eb965164025a47caf39893541577c80 (patch) | |
| tree | 20c61c9fb6f97cee225b25c7834b2baba3e988cf | |
| parent | 20f9ba83c20ad27c1b24f1b48e2f4c1ad38ef9ac (diff) | |
| download | git-sonar-990756613eb965164025a47caf39893541577c80.tar.gz git-sonar-990756613eb965164025a47caf39893541577c80.zip | |
Add configuration variables for default unprintable markers
Add GIT_SONAR_COLOR_PREFIX and GIT_SONAR_COLOR_SUFFIX, which control the
shell prompt unprintable character markers used by default color codes
in git-sonar. These are added as a convenience so that a user on zsh,
for example, doesn't need to redefine every color setting when the only
thing they need to replace is the \001 and \002.
This is similar to the old shell options (--bash, --zsh, --fish) from
git-radar, but is open-ended so that the user may configure exactly what
is needed for any old shell, without the need to teach git-sonar
specific details in advance. See also c4da5e91d053 ("Merge
bash/zsh/fish color modes together").
Signed-off-by: Matt Hunter <m@lfurio.us>
| -rwxr-xr-x | git-sonar | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -68,15 +68,17 @@ precheck_status=$? # Initialize configuration variables and set default values if not provided by # the environment. Note: ANSI escape codes (and other unprintable sequences) -# must be enclosed by a \001 byte (ASCII start of heading) at the start and a -# \002 byte (ASCII start of text) at the end - some shells rely on this to -# correctly track the length of their rendered prompt. -COLOR_GRAY="\\001\\033[1;30m\\002" -COLOR_RED="\\001\\033[1;31m\\002" -COLOR_GREEN="\\001\\033[1;32m\\002" -COLOR_YELLOW="\\001\\033[1;33m\\002" -COLOR_WHITE="\\001\\033[1;37m\\002" -COLOR_DEF="${GIT_SONAR_DEFAULT_COLOR:-"\\001\\033[0m\\002"}" +# usually need to be enclosed within a pair of markers to help the user's shell +# correctly track the length of the rendered prompt and handle text wrapping. +# These default markers are for bash. +CS="${GIT_SONAR_COLOR_PREFIX:-"\\001"}" # ASCII start of heading +CE="${GIT_SONAR_COLOR_SUFFIX:-"\\002"}" # ASCII start of text +COLOR_DEF="${GIT_SONAR_DEFAULT_COLOR:-"${CS}\\033[0m${CE}"}" +COLOR_GRAY="${CS}\\033[1;30m${CE}" +COLOR_RED="${CS}\\033[1;31m${CE}" +COLOR_GREEN="${CS}\\033[1;32m${CE}" +COLOR_YELLOW="${CS}\\033[1;33m${CE}" +COLOR_WHITE="${CS}\\033[1;37m${CE}" FETCH_TIME="${GIT_SONAR_FETCH_TIME:-"300"}" |
