Skip to content

Status line setup

Claude Code statusline — Arun/Matt’s setup

Section titled “Claude Code statusline — Arun/Matt’s setup”

Two-piece status line: git state on the left, context-window % on the right.

chessx/chessx-mr | main | S: 0 | U: 2 | A: 1 | 73% left
  • S staged · U unstaged · A untracked · then a vertical bar, then ccstatusline context-remaining %.
  • Falls back to a short cwd outside git repos.

~/.claude/settings.json:

{
"statusLine": {
"type": "command",
"command": "bash ~/.claude/statusline-wrapper.sh"
}
}

~/.claude/statusline-wrapper.sh — composes git info + npx ccstatusline:

#!/bin/bash
eval "$(/opt/homebrew/bin/brew shellenv)"
input=$(cat)
git_info=$(echo "$input" | bash ~/.claude/statusline-command.sh)
context_pct=$(echo "$input" | npx ccstatusline)
printf '%s | %s' "$git_info" "$context_pct"

~/.claude/statusline-command.sh — git half (repo, branch, file counts, ANSI colour):

#!/bin/bash
input=$(cat)
cwd=$(echo "$input" | sed -n 's/.*"current_dir":"\([^"]*\)".*/\1/p')
if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then
repo_name=$(echo "$cwd" | sed "s|^$HOME/||")
branch=$(git -C "$cwd" --no-optional-locks rev-parse --abbrev-ref HEAD 2>/dev/null)
staged=$(git -C "$cwd" --no-optional-locks diff --cached --name-only 2>/dev/null | wc -l | tr -d ' ')
unstaged=$(git -C "$cwd" --no-optional-locks diff --name-only 2>/dev/null | wc -l | tr -d ' ')
untracked=$(git -C "$cwd" --no-optional-locks ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d ' ')
printf '\033[01;36m%s\033[00m | \033[01;32m%s\033[00m | S: \033[01;33m%s\033[00m | U: \033[01;33m%s\033[00m | A: \033[01;33m%s\033[00m' \
"$repo_name" "$branch" "$staged" "$unstaged" "$untracked"
else
if [ "$cwd" = "$HOME" ]; then short_cwd="~"; else short_cwd=$(echo "$cwd" | sed "s|^$HOME/||"); fi
printf '\033[01;36m%s\033[00m' "$short_cwd"
fi
Terminal window
# 1. drop both scripts into ~/.claude/
chmod +x ~/.claude/statusline-wrapper.sh ~/.claude/statusline-command.sh
# 2. add the statusLine block to ~/.claude/settings.json (above)
# 3. ccstatusline runs via npx; no global install needed
# first run pulls it; subsequent runs are cached

Restart Claude Code (or start a new session) — the status line appears at the bottom of the input area.

  • The brew shellenv line in the wrapper is needed because Claude Code spawns the statusline command in a minimal shell without your interactive PATH; without it npx is not found on Apple Silicon.
  • --no-optional-locks prevents the status line from blocking when another git process holds the index lock.
  • Pattern credit: Matt Pocock; tweaks (file-count granularity, npx wrapper) by Arun.