/color command: support arbitrary hex colors (terminals already support truecolor)
Summary
The /color command currently accepts only 8 named colors: red, blue, green, yellow, purple, orange, pink, cyan, default. Modern terminals (VS Code integrated terminal, iTerm2, Ghostty, Kitty, WezTerm, Alacritty) all support 24-bit true color via COLORTERM=truecolor. The named-color limitation is a CLI UI decision, not a terminal constraint.
Use case
In multi-agent projects where multiple Claude Code sessions collaborate on the same repo, each session gets a persistent identity — a name and a color stored in a project config file. The hex color is the canonical identifier used in documentation, rendered surfaces, and session provenance tracking.
The current 8-color palette forces lossy quantization: two sessions whose canonical colors are #B45309 (amber) and #78716C (warm stone gray) both map to orange, producing a collision that defeats the purpose of per-session color identity.
Proposed change
Accept hex colors in /color:
/color #78716C
Detection: if the argument starts with # and is a valid 6-digit hex color, use 24-bit ANSI escape sequences (\033[38;2;R;G;Bm) to render it. Named colors continue to work unchanged.
Graceful degradation: if COLORTERM is not truecolor or 24bit, fall back to nearest named color (existing behavior) and optionally warn: Terminal does not support truecolor; using nearest approximation: orange.
Implementation sketch
if (arg.startsWith('#') && /^#[0-9a-f]{6}$/i.test(arg)) {
const r = parseInt(arg.slice(1,3), 16)
const g = parseInt(arg.slice(3,5), 16)
const b = parseInt(arg.slice(5,7), 16)
if (process.env.COLORTERM === 'truecolor' || process.env.COLORTERM === '24bit') {
setSessionColor(`\x1b[38;2;${r};${g};${b}m`)
} else {
setSessionColor(nearestNamedColor(r, g, b)) // existing fallback
}
}
Expected behavior after fix
/color #78716C → session renders in warm stone gray
/color orange → unchanged, still works
/color #xyz → error: "Invalid hex color"
Environment
- macOS, VS Code integrated terminal + iTerm2
COLORTERM=truecolorconfirmed in both
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗