statusLine hook output: leading whitespace stripped, preventing right-aligned content

Resolved 💬 4 comments Opened Feb 27, 2026 by deepthawtz Closed Mar 8, 2026

Summary

The statusLine hook strips leading whitespace from script output, making it impossible to right-align content in the status bar. Users who want to place statusline content in the bottom-right corner (e.g. cwd, model name) cannot do so.

Environment

  • Claude Code: v2.1.62
  • OS: macOS 15.3 (Darwin 25.3.0)
  • Terminal: iTerm2
  • Shell: zsh

Steps to Reproduce

  1. Configure a statusLine hook in ~/.claude/settings.json:

\\\json
{
"statusLine": "~/.claude/statusline-command.sh"
}
\
\\

  1. Create ~/.claude/statusline-command.sh:

\\\`bash
#!/usr/bin/env bash
input=$(cat)
text="hello world"

Attempt 1: printf with fixed-width field (leading spaces)

printf "%100s" "$text"
\\\`

  1. Launch claude in any directory.

Expected: Status bar shows hello world pushed ~100 chars to the right with leading spaces.
Actual: Status bar shows hello world with no leading spaces — they are stripped.

Additional Reproduction Cases

Attempt 2: Explicit space padding
\\\bash
printf "%80s%s" "" "$text" # leading spaces stripped
\
\\

Attempt 3: Dynamic terminal width
\\\`bash

Neither $COLUMNS nor tput cols is available in the hook subprocess env

width="${COLUMNS:-$(tput cols 2>/dev/null)}"

width is empty — falls back gracefully but can't right-align

\\\`

Attempt 4: Hardcoded terminal width (178 cols)
\\\bash
width=178
len=${#text}
pad=$(( width - len ))
printf "%${pad}s%s" "" "$text" # leading spaces still stripped
\
\\

All four approaches produce identical left-aligned output. Leading whitespace is removed regardless of how it is generated.

Root Cause Hypothesis

The statusline renderer appears to call .trim() or equivalent on the hook's stdout before rendering, discarding all leading whitespace. Additionally, $COLUMNS is not passed to the hook subprocess environment and tput cols has no TTY to query, so scripts cannot self-calculate terminal width even as a workaround.

Feature Request

One or more of:

  1. Preserve leading whitespace in statusline hook output so scripts can manually pad
  2. Expose terminal width in the JSON piped to the hook (e.g. terminal.cols)
  3. Add native right-align support — e.g. a JSON output format like {"left": "...", "right": "..."} or a separator token like %= in vim's statusline

Option 3 would be the most ergonomic and consistent with how status bars work in tools like vim/neovim.

Use Case

Power users running multiple Claude Code sessions simultaneously need a way to identify which session is which at a glance. The cwd is the natural differentiator and the bottom-right of the status bar is the natural place for it — analogous to how vim shows file position bottom-right.

View original on GitHub ↗

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