Last active
July 15, 2026 17:17
-
-
Save koteitan/36d49db167bb20dd68fe919941eea4ca to your computer and use it in GitHub Desktop.
statusLine command for Claude Code
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 | |
| # statusLine command for Claude Code | |
| # save it as ~/.claude/statusline-command.sh | |
| input=$(cat) | |
| host=$(hostname -s) | |
| dir=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty') | |
| [ -z "$dir" ] && dir=$(pwd) | |
| model_id=$(echo "$input" | jq -r '.model.id // empty') | |
| effort=$(echo "$input" | jq -r '.effort.level // empty') | |
| ctx=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| five=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty') | |
| week=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') | |
| # Render a 10-char colored gauge for a percentage (integer/float) or empty. | |
| render_bar() { | |
| local val="$1" | |
| local width=10 | |
| local out="" i | |
| # absent -> gray empty bar, no text | |
| if [ -z "$val" ]; then | |
| for ((i=0; i<width; i++)); do | |
| out+=$(printf '\033[38;5;245;48;5;236m ') | |
| done | |
| printf '%s\033[0m' "$out" | |
| return | |
| fi | |
| local p | |
| p=$(printf '%.0f' "$val") | |
| [ "$p" -lt 0 ] && p=0 | |
| [ "$p" -gt 100 ] && p=100 | |
| # hue: dark / light 256-color codes | |
| local dark light | |
| if [ "$p" -lt 80 ]; then dark=22; light=120 # green | |
| elif [ "$p" -lt 100 ]; then dark=94; light=215 # orange | |
| else dark=88; light=210 # red | |
| fi | |
| local filled=$(( p / 10 )) # floor: only 100% fills all 10 | |
| local text="${p}%" # integer percent (source resolution is 1) | |
| local L=${#text} | |
| local start | |
| if [ "$p" -lt 50 ]; then | |
| start=$(( width - L )) # end at rightmost empty cell | |
| else | |
| start=0 # start at leftmost filled cell | |
| fi | |
| (( start < 0 )) && start=0 | |
| (( start + L > width )) && start=$(( width - L )) | |
| local ch fg bg | |
| for ((i=0; i<width; i++)); do | |
| ch=' ' | |
| if (( i >= start && i < start + L )); then | |
| ch=${text:$((i - start)):1} | |
| fi | |
| if (( i < filled )); then | |
| fg=$dark; bg=$light | |
| else | |
| fg=$light; bg=$dark | |
| fi | |
| out+=$(printf '\033[38;5;%d;48;5;%dm%s' "$fg" "$bg" "$ch") | |
| done | |
| printf '%s\033[0m' "$out" | |
| } | |
| ctx_bar=$(render_bar "$ctx") | |
| five_bar=$(render_bar "$five") | |
| week_bar=$(render_bar "$week") | |
| model_display="" | |
| [ -n "$model_id" ] && model_display=$(printf '\033[01;36m%s\033[00m' "$model_id") | |
| effort_display="" | |
| [ -n "$effort" ] && effort_display=$(printf ' \033[01;35m%s\033[00m' "$effort") | |
| printf '\033[01;34m%s\033[00m:\033[01;33m%s\033[00m\n' "$host" "$dir" | |
| printf 'ctx:[%s] 5h:[%s] w:[%s] %s%s' "$ctx_bar" "$five_bar" "$week_bar" "$model_display" "$effort_display" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
screen shot
