Reverse-engineered from ~/.claude/statusline-command.sh.
Paste the block below into Claude Code, either as a plain message or after /statusline.
Set up my Claude Code status line as a bash script at ~/.claude/statusline-command.sh,
and register it in ~/.claude/settings.json under the "statusLine" key as
{"type": "command", "command": "bash /Users/<me>/.claude/statusline-command.sh"}.
The script reads the session JSON from stdin and parses it with jq. Fields to read:
.workspace.current_dir // .cwd -> working directory
.context_window.total_input_tokens -> token count
.model.display_name -> model name
.context_window.used_percentage -> context used
.context_window.remaining_percentage -> context left
.rate_limits.five_hour.used_percentage -> 5-hour limit
.rate_limits.seven_day.used_percentage -> weekly limit
Render six space-separated badges, each as colored ANSI background blocks with a
one-space pad inside, reset after each. Left to right:
1. TOKENS - cyan background, black text. Show "12.3k tokens" when >= 1000
(one decimal), otherwise "456 tokens". Show "0 tokens" if missing.
2. MODEL - blue background, white text. Just the display name. Omit if empty.
3. CONTEXT - text is "ctx: 42% used / 58% left" with both percentages rounded to
whole numbers. Background is green under 60%, yellow at 60-84%, red at 85%+,
based on used percentage. If the data is missing, gray background, white text,
and the text "ctx: --".
4. 5-HOUR LIMIT - "5h: 37%", same green/yellow/red thresholds on used percentage.
Gray with "5h: --" if missing.
5. WEEKLY LIMIT - "wk: 12%", identical rules to the 5h badge.
6. GIT BRANCH - orange background (256-color 208), black text, prefixed with the
⎇ character. Get it with
`git --no-optional-locks -C "$cwd" branch --show-current`, falling back to
`rev-parse --short HEAD` on a detached HEAD. Omit the badge entirely if the
directory is not a git repo.
Use --no-optional-locks so the status line never fights the user's git commands.
Make the script executable.
/Users/<me>/is a placeholder — the realsettings.jsonneeds their own absolute path, since Claude Code does not expand~in thestatusLinecommand.- Depends on
jqandawk.awkis everywhere;jqmay needbrew install jq. - Sending
~/.claude/statusline-command.shdirectly is more faithful than regenerating from this prompt — it is 113 lines and self-contained.