Statusline: support right/center alignment

Resolved 💬 1 comment Opened Jun 1, 2026 by radumarias Closed Jul 5, 2026

Summary

Statusline scripts can only render left-aligned. Any attempt to right-align or center the content fails because Claude Code's TUI processes the script output in ways that prevent positional control.

What I tried

I have a working statusline script that renders e.g.
[Opus] my-project · 🌿 my-branch · ctx:14% · $124.23 · ⏰ 7h 30m · 5h:60% · wk:16%

To right-align (or center) this, I tried, in order:

  1. Leading whitespace paddingprintf '%*s%s' "$pad" "" "$line". Result: spaces are stripped, content appears left-aligned. (TUI seems to apply trimStart() or equivalent.)
  2. CHA cursor positioning — emit \e[<col>G before the content to move the cursor to an absolute column. Result: escape is sanitized away, content still appears left-aligned. (TUI permits SGR color escapes but not cursor-positioning CSI sequences.)
  3. ZWSP (U+200B) + spaces — prepend a zero-width space so leading whitespace stripping wouldn't see ASCII whitespace at index 0, then the regular spaces. Result: padding survives and content shifts toward the right edge — but the TUI also miscounts the line's visible width (likely counts ZWSP as 1 cell, or counts bytes), and the tail of the content is truncated. Reducing the pad to leave a safety margin doesn't help.
  4. Window resize — when the user shrinks the terminal with the ZWSP-padded line in place, the line is hidden entirely (the TUI seems to give up on rows that don't fit).

So: leading whitespace doesn't survive, CHA escapes don't survive, ZWSP-anchored padding survives but breaks truncation, and the script has no way to emit "place the content at column N" without one of those.

What I want

Either of the following would unblock this:

Option A (preferred): alignment hint in the contract. The statusline script receives JSON on stdin. Add an alignment hint on the output side — e.g., a recognised control prefix in stdout (\x01align=right\x02…), a CLAUDE_STATUSLINE_ALIGN=right env var the TUI reads, or accept a JSON output mode (if stdout starts with {).

Option B: preserve cursor-positioning CSI sequences (\e[<col>G). They're invisible to the rendered width and let the script self-position. Currently the TUI strips them; if it passed them through to the terminal, scripts could right-align natively.

Option C: don't trim leading whitespace. Same outcome with less work — leading spaces would let scripts pad themselves into position.

Bonus: many users (myself included) would also like to either embed or co-render with the ⏵⏵ auto mode on (shift+tab to cycle) indicator on the same row. Today the auto-mode indicator and the statusline live on adjacent but separate rows, with no way to merge.

Environment

  • Claude Code 2.1.159
  • Terminal: GNOME Console + Warp (Linux), both behave the same
  • Statusline configured via ~/.claude/settings.json (statusLine.type: "command")
  • Verified $COLUMNS is exported into the subprocess (255 in my session), so width detection isn't the bottleneck

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗