Skip to content

Instantly share code, notes, and snippets.

@JonCanning
Created March 30, 2026 19:29
Show Gist options
  • Select an option

  • Save JonCanning/a86f55c608aad931ddd6223974b6410f to your computer and use it in GitHub Desktop.

Select an option

Save JonCanning/a86f55c608aad931ddd6223974b6410f to your computer and use it in GitHub Desktop.
Claude statusline
#!/bin/bash
input=$(cat)
j() { echo "$input" | jq -r "$1"; }
MODEL=$(j '.model.display_name')
BRANCH=$(git branch --show-current 2>/dev/null)
DIR=$(j '.workspace.current_dir')
FIVE_PCT=$(j '.rate_limits.five_hour.used_percentage // 0' | cut -d. -f1)
FIVE_RESET=$(j '.rate_limits.five_hour.resets_at // 0')
SEVEN_PCT=$(j '.rate_limits.seven_day.used_percentage // 0' | cut -d. -f1)
SEVEN_RESET=$(j '.rate_limits.seven_day.resets_at // 0')
CTX_PCT=$(j '.context_window.used_percentage // 0' | cut -d. -f1)
CTX_USED=$(j '.context_window.total_input_tokens // 0')
CTX_SIZE=$(j '.context_window.context_window_size // 0')
R='\033[0m'
fmt_reset() {
local now reset_at diff h m
now=$(date +%s)
reset_at=$1
[ "$reset_at" = "0" ] && echo "?" && return
diff=$((reset_at - now))
[ "$diff" -le 0 ] && echo "now" && return
d=$((diff / 86400))
h=$(((diff % 86400) / 3600))
m=$(((diff % 3600) / 60))
[ "$d" -gt 0 ] && echo "${d}d ${h}h ${m}m" || { [ "$h" -gt 0 ] && echo "${h}h ${m}m" || echo "${m}m"; }
}
ACTUAL_USED=$(awk "BEGIN{printf \"%.1f\", $CTX_SIZE * $CTX_PCT / 100 / 1000}")
SIZE_K=$((CTX_SIZE / 1000))
LINE1="$MODEL"
[ -n "$BRANCH" ] && LINE1="$LINE1 | $BRANCH"
LINE1="$LINE1 | $DIR"
echo -e "\033[44m ${LINE1} ${R}"
echo -e "\033[43;30m session:${FIVE_PCT}% $(fmt_reset "$FIVE_RESET") ${R} \033[45m weekly:${SEVEN_PCT}% $(fmt_reset "$SEVEN_RESET") ${R}"
ACTUAL_K_INT=$((CTX_SIZE * CTX_PCT / 100 / 1000))
if [ "$ACTUAL_K_INT" -ge 100 ]; then BAR_CLR='\033[31m'
elif [ "$ACTUAL_K_INT" -ge 80 ]; then BAR_CLR='\033[33m'
else BAR_CLR='\033[32m'; fi
FILLED=$((CTX_PCT / 5))
EMPTY=$((20 - FILLED))
BAR=""
[ "$FILLED" -gt 0 ] && printf -v F "%${FILLED}s" && BAR="${F// /█}"
[ "$EMPTY" -gt 0 ] && printf -v E "%${EMPTY}s" && BAR="${BAR}${E// /░}"
echo -e " ctx:${CTX_PCT}% ${BAR_CLR}${BAR}${R} ${ACTUAL_USED}k/${SIZE_K}k"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment