[BUG] Status line escape codes displayed literally when using dynamic color variables

Resolved 💬 3 comments Opened Jan 6, 2026 by lappemic Closed Feb 21, 2026

Description

When configuring a custom status line via /terminal-setup, the generated command uses dynamic ANSI color codes stored in variables. These escape sequences are displayed literally instead of being interpreted as colors.

Environment

  • Claude Code version: 2.0.76
  • OS: macOS (Darwin 24.2.0)
  • Shell: zsh with Powerlevel10k

Steps to Reproduce

  1. Run /terminal-setup to configure a status line with context window percentage
  2. The generated status line command assigns color codes dynamically based on usage percentage:

``bash
[ $pct -lt 50 ] && col="\\033[32m" || col="\\033[33m"
ctx=$(printf " %s%d%%" "$col" "$pct")
``

  1. The output displays the literal escape sequence instead of colored text:

``
\033[32m18%
``

Expected Behavior

The percentage should be displayed in green/yellow/red based on the context window usage, with the escape code interpreted.

Actual Behavior

The literal string \033[32m is shown before the percentage value.

Root Cause

The printf format specifier %s does not interpret backslash escape sequences in its arguments. It prints the variable contents literally.

Solution

Use %b instead of %s for arguments containing escape sequences. The %b format specifier interprets backslash escapes:

# Before (broken)
ctx=$(printf " %s%d%%" "$col" "$pct")

# After (fixed)
ctx=$(printf " %b%d%%" "$col" "$pct")

Note: Escape codes hardcoded directly in the format string (e.g., printf "\033[32m%s") work correctly because printf interprets escapes in the format string itself. The issue only affects escape codes passed as arguments via %s.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗