fix(docs): use ANSI-C quoting for bash statusline badge example#57
Merged
JuliusBrussee merged 1 commit intoJuliusBrussee:mainfrom Apr 11, 2026
Merged
Conversation
The bash snippet in hooks/README.md uses double-quoted escape sequences like '\033[38;5;172m[CAVEMAN]\033[0m', but bash does not interpret backslash escapes inside double quotes. Users who copy-paste the example get the literal 19-character string '\033[38;5;172m[CAVEMAN]\033[0m' in their statusline instead of a colored badge. Fix by switching to ANSI-C quoted strings ($'...'), where bash does interpret \033 as the ESC character. For the mode-variant line that needs to interpolate the uppercase suffix, adjacent string concatenation preserves both the ANSI-C literal portions and the double-quoted variable expansion. Verified via 'bash -c ... | cat -v' that both variants now render the actual ESC character (0x1B, shown as ^[ by cat -v). Before: "\033[38;5;172m[CAVEMAN]\033[0m" (literal string) After: $'\033[38;5;172m[CAVEMAN]\033[0m' (interpreted escape)
There was a problem hiding this comment.
Pull request overview
This PR fixes a copy-paste bug in the hooks/README.md statusline badge example by switching from double-quoted strings (which keep \033 literal in bash) to ANSI-C quoting so the snippet produces real terminal escape sequences.
Changes:
- Replace
"\033..."with$'\033...'for the non-suffixed badge example. - Use bash adjacent-string concatenation to keep ANSI escapes literal while still expanding
${caveman_suffix}.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small docs fix — the bash statusline snippet in `hooks/README.md` has a real bug.
Problem
The current snippet uses double-quoted escape sequences:
```bash
caveman_text="\033[38;5;172m[CAVEMAN]\033[0m"
```
Bash does not interpret backslash escapes inside double quotes. Users who copy-paste this get the literal 19-character string `\033[38;5;172m[CAVEMAN]\033[0m` in their statusline instead of a colored badge.
You can verify with `printf`:
```bash
$ caveman_text="\033[38;5;172m[CAVEMAN]\033[0m"
$ printf '%s\n' "$caveman_text" | cat -v
\033[38;5;172m[CAVEMAN]\033[0m
```
No ESC character — just literal text.
Fix
Switch to ANSI-C quoted strings (`$'...'`), which bash does interpret:
```bash
caveman_text=$'\033[38;5;172m[CAVEMAN]\033[0m'
```
For the mode-variant line that needs to interpolate `${caveman_suffix}`, adjacent string concatenation preserves both the ANSI-C literal portions and the double-quoted expansion:
```bash
caveman_text=$'\033[38;5;172m[CAVEMAN:'"${caveman_suffix}"$']\033[0m'
```
Verified with `bash -c ... | cat -v`:
```
^[[38;5;172m[CAVEMAN]^[[0m
^[[38;5;172m[CAVEMAN:ULTRA]^[[0m
```
`^[` is the visible representation of ESC (0x1B). Both variants now produce real escape sequences, and the badge renders with color in a terminal.
Scope
This is one of a small batch of docs and install.sh quality-of-life PRs I'm sending today. Each one is independent and can be merged in any order. Close any that don't fit your vision — no pressure. 🪨