Created
January 9, 2026 08:51
-
-
Save FrancescoSaverioZuppichini/932fef65be5d1845e7673840a1725d53 to your computer and use it in GitHub Desktop.
claude-code-status-line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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" |
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Installation
jq~/.claude/statusline.sh~/.claude/settings.json: