Skip to content

Instantly share code, notes, and snippets.

@FrancescoSaverioZuppichini
Created January 9, 2026 08:51
Show Gist options
  • Select an option

  • Save FrancescoSaverioZuppichini/932fef65be5d1845e7673840a1725d53 to your computer and use it in GitHub Desktop.

Select an option

Save FrancescoSaverioZuppichini/932fef65be5d1845e7673840a1725d53 to your computer and use it in GitHub Desktop.
claude-code-status-line
#!/bin/bash
input=$(cat)
model=$(echo "$input" | jq -r '.model.display_name // .model.id // "unknown"')
cwd=$(echo "$input" | jq -r '.workspace.current_dir // "."')
total=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')
cache_read=$(echo "$input" | jq -r '.context_window.current_usage.cache_read_input_tokens // 0')
cache_create=$(echo "$input" | jq -r '.context_window.current_usage.cache_creation_input_tokens // 0')
input_tok=$(echo "$input" | jq -r '.context_window.current_usage.input_tokens // 0')
output_tok=$(echo "$input" | jq -r '.context_window.current_usage.output_tokens // 0')
used=$((cache_read + cache_create + input_tok + output_tok))
pct=$((used * 100 / total))
filled=$((pct / 10))
bar="[$(printf '%*s' $filled '' | tr ' ' '=')$(printf '%*s' $((10-filled)) '' | tr ' ' '-')]"
fmt() {
local n=$1
if [ "$n" -ge 1000000 ]; then
awk "BEGIN{printf \"%.1fM\", $n/1000000}"
elif [ "$n" -ge 1000 ]; then
awk "BEGIN{printf \"%.1fK\", $n/1000}"
else
echo "$n"
fi
}
used_fmt=$(fmt $used)
total_fmt=$(fmt $total)
branch=$(git -C "$cwd" branch --show-current 2>/dev/null)
C='\033[36m' Y='\033[33m' G='\033[32m' B='\033[34m' M='\033[35m' W='\033[37m' D='\033[2m' R='\033[0m'
out="${C}${model}${R} ${D}|${R} ${Y}${bar}${R} ${D}|${R} ${G}${pct}%${R} ${D}|${R} ${B}${used_fmt} / ${total_fmt}${R}"
[ -n "$branch" ] && out+=" ${D}|${R} ${M}${branch}${R}"
out+=" ${D}|${R} ${W}$(basename "$cwd")${R}"
printf "%b" "$out"
@FrancescoSaverioZuppichini
Copy link
Author

FrancescoSaverioZuppichini commented Jan 9, 2026

Installation

  1. Install jq
  2. Save this script into ~/.claude/statusline.sh
  3. Update the config - add this to ~/.claude/settings.json:
 "statusLine": {
   "type": "command",
   "command": "/bin/bash ~/.claude/statusline.sh"
 }

@FrancescoSaverioZuppichini
Copy link
Author

Screenshot 2026-01-09 at 09 52 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment