Support ANSI color codes in bash command output
Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened Jan 17, 2026 · closed Jan 17, 2026
Summary
Bash commands that produce colored output (like git log, ls --color, grep --color) have their ANSI escape codes stripped or escaped before being displayed in the terminal. The user's terminal (e.g., Ghostty, iTerm2) is fully capable of rendering these codes, but Claude Code's output pipeline prevents them from reaching the terminal.
Current Behavior
- Command runs and produces ANSI codes (verified by capturing with
script -q /dev/null) - Claude Code captures stdout as text
- ANSI codes are escaped/stripped during processing
- Output appears as plain uncolored text
Example - running git log --oneline --color=always shows plain text instead of the colored branch names, commit hashes, etc.
Desired Behavior
ANSI escape codes should be passed through to the terminal unescaped, allowing the user's terminal emulator to render colors as intended.
Possible Solutions
- A config option like
terminal.preserveAnsiCodes: true - A
--raw-outputflag for bash commands - Detecting when stdout is a TTY and passing codes through in that case
Environment
- Terminal: Ghostty (but applies to any terminal with ANSI support)
- OS: macOS
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Related Issues
There seems to be a common theme across these issues: users want ANSI codes preserved and rendered in various output contexts. #18269 in particular may have significant overlap with this request, as both are about tool/script output having colors stripped before reaching the terminal.
Update: #16790 is very similar - also about ANSI escape sequences being stripped from Bash tool output. That issue focuses on true color (24-bit SGR codes), while this one covers ANSI codes more broadly, but the underlying problem is the same: escape sequences are stripped before tool output reaches the terminal.
#16790 may be the canonical issue for this. Happy to close this as duplicate if that's preferred.
Closing this - I mistakenly blamed Claude for git's behavior:
Testing Colors
These tests were conducted on Ghostty v1.2.3 on macOS Tahoe 26.2
Claude Slash Commands
To prove this works with a minimal example, I created a new command file
.claude/commands/claude-color-test.mdwith the attached content claude-color-test.md:````bash
Run this shell command to test terminal colors:
````
Run claude and use the slash command skill with
/claude-color-test... after a permission prompt:<img width="2018" height="264" alt="Image" src="https://github.com/user-attachments/assets/0b8f96a8-5b3e-4716-8957-04617f1b3230" />
Using the Bash Bang ! Command
I also used a simple example to test colors in Claude Code with the ! bash command and it worked there as well:
This is the command I paste after hitting !
Running with the ! bash command this worked:
<img width="1492" height="198" alt="Image" src="https://github.com/user-attachments/assets/da96f590-d18a-49d2-ad7e-f0159a8e64b1" />
----
So -- yep, I was wrong, it works great!
Leaving this in case it may help someone in the future.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.