A custom status line script that shows the current project directory, git branch, context window usage, and rate limits — color-coded by severity.

📁 claude-code-wsl2-setup | 🌿 main | [··········] 6% | 5h:10% | W:95%
.workspace.current_dir (fallback: $PWD), prefixed with 📁🌿 (only shown inside git repos)1. Install the script
Requires Bash 4.4+, jq, and Git for the branch display. On Ubuntu inside WSL:
sudo apt install jq git
From the cloned repository, install the script. If the destination already exists, back it up before replacing it:
mkdir -p ~/.claude
if [ -f ~/.claude/statusline-command.sh ]; then
cp --backup=numbered ~/.claude/statusline-command.sh ~/.claude/statusline-command.sh.bak
fi
install -m755 bin/statusline-command.sh ~/.claude/statusline-command.sh
2. Merge the setting into ~/.claude/settings.json
Keep the rest of your settings. Back up the file first; see maintenance.
{
"statusLine": {
"type": "command",
"command": "bash ~/.claude/statusline-command.sh"
}
}
Restart Claude Code. The status line appears at the bottom of the interface.
Claude Code pipes a JSON blob to the script’s stdin on every refresh. The script reads four fields using jq:
| Field | JSON path |
|---|---|
| Working dir | .workspace.current_dir |
| Context % | .context_window.used_percentage |
| 5-hour usage % | .rate_limits.five_hour.used_percentage |
| 7-day usage % | .rate_limits.seven_day.used_percentage |
The git branch is resolved by running git symbolic-ref against the working directory from the JSON — no cd needed, and --no-optional-locks avoids touching .git/ lock files. On a detached HEAD (mid-rebase, mid-bisect) it falls back to a short SHA.
Missing or null percentages are omitted independently. The script preserves empty fields with NUL separators, so weekly usage cannot shift into the five-hour or context display. Invalid numeric text and implausibly large values (more than six integer digits) are omitted, and the context bar is capped at 100%. Malformed JSON exits with an error instead of rendering misleading data.
The Claude Code statusline reference describes the input fields. Rate limits may be absent, including before the first API response or for accounts without the supported subscription data.
The filled cells inherit the context severity color, while unused cells use dim gray · characters. This keeps a nearly empty bar from looking like a solid block in terminal themes where ░ renders too heavily.
Output uses printf '%s', not %b: a directory or branch name containing a backslash would otherwise be mangled by escape interpretation.
Run this sample without starting Claude Code:
printf '%s' '{"workspace":{"current_dir":"/tmp"},"context_window":{"used_percentage":null},"rate_limits":{"five_hour":{"used_percentage":34},"seven_day":{"used_percentage":56}}}' | bash ~/.claude/statusline-command.sh
Expect 5h:34% and W:56%, with no context bar. Then open Claude Code and confirm
that the statusline appears. Missing subscription data should leave only the
available parts visible.
For the repository’s regression checks, run this from the cloned repository:
bash scripts/check.sh
Remove only this statusLine entry from ~/.claude/settings.json, or restore your
previous statusline setting. Restart Claude Code, then remove the installed script
if nothing else uses it:
rm -f ~/.claude/statusline-command.sh
If you replaced a script, restore your saved copy instead. Keep other settings intact.