Claude Code Custom Status Bar
Custom status line configuration for Claude Code CLI that displays useful information globally across all projects.
Status Line Display
Opus 4.5 | 15% | 31k/200k | main | subagents
Components Displayed
| Component | Description | Source |
|---|---|---|
| Model name | e.g., “Opus 4.5” | .model.display_name |
| Usage % | Context window usage | .context_window.used_percentage |
| Token count | Used/Total (e.g., 31k/200k) | Calculated from input + output tokens |
| Git branch | Current branch name | git branch --show-current |
| Subagents | Shown when subagents active | .subagent field |
Configuration Files
Script: ~/.claude/statusline.sh
#!/bin/bash
input=$(cat)
# Extract values using jq
MODEL=$(echo "$input" | jq -r '.model.display_name')
USED_PERCENT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
INPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
OUTPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
CONTEXT_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size // 0')
# Calculate total tokens as "31k/200k"
TOTAL_TOKENS=$((INPUT_TOKENS + OUTPUT_TOKENS))
TOTAL_K=$((TOTAL_TOKENS / 1000))
CONTEXT_K=$((CONTEXT_SIZE / 1000))
TOKEN_DISPLAY="${TOTAL_K}k/${CONTEXT_K}k"
# Get git branch
GIT_BRANCH=""
if git rev-parse --git-dir > /dev/null 2>&1; then
BRANCH=$(git branch --show-current 2>/dev/null)
[ -n "$BRANCH" ] && GIT_BRANCH=" | $BRANCH"
fi
# Check subagents
SUBAGENT=""
if echo "$input" | jq -e '.subagent' > /dev/null 2>&1; then
SUBAGENT=" | subagents"
fi
echo "$MODEL | ${USED_PERCENT}% | $TOKEN_DISPLAY$GIT_BRANCH$SUBAGENT"
Settings: ~/.claude/settings.json
{
"statusLine": {
"type": "command",
"command": "/Users/chrislee/.claude/statusline.sh",
"padding": 0
}
}
Requirements
jqmust be installed (brew install jq)- Script must be executable (
chmod +x ~/.claude/statusline.sh)
Performance Notes
| Component | Resource Cost |
|---|---|
| jq parsing | Low (in-memory JSON) |
| Git commands | Low (local file read) |
| Bash arithmetic | Very Low |
Not included: MCP server status (too slow – requires network calls to each server, ~3-5 seconds vs ~5ms for current components)
Activation
Restart Claude Code after configuration. Status line applies globally across all projects.
