Skip to content

Instantly share code, notes, and snippets.

@VinciGit00
Forked from FrancescoSaverioZuppichini/statusline.sh
Created January 9, 2026 10:23
Show Gist options
  • Select an option

  • Save VinciGit00/8b62531e6abdac3f55ccb00a66d2dfb7 to your computer and use it in GitHub Desktop.

Select an option

Save VinciGit00/8b62531e6abdac3f55ccb00a66d2dfb7 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment