Original Reddit post

Give this a try and let me know your thoughts. Save the file in your user folder in .claude/statusline-command.sh Example: Opus 4.7 (1M context) | [█░░░░░░░░░] 11% | branch:main | 5h:44% | 7d:6% | session:1h0m #!/usr/bin/env bash # ANSI colors GREEN=“\033[32m” YELLOW=“\033[33m” RED=“\033[31m” ORANGE=“\033[38;5;214m” CYAN=“\033[38;5;45m” WHITE=“\033[37m” RESET=“\033[0m” input=$(cat) # ── Model name & context size ───────────────────────────────────────────────── model_name=$(echo “$input” | jq -r ‘.model.display_name // empty’) ctx_size=$(echo “$input” | jq -r ‘.context_window.context_window_size // empty’) if [ -n “$ctx_size” ] && [ “$ctx_size” -ge 1000000 ] 2>/dev/null; then ctx_label=“$(( ctx_size / 1000000 ))M context” elif [ -n “$ctx_size” ] && [ “$ctx_size” -ge 1000 ] 2>/dev/null; then ctx_label=“$(( ctx_size / 1000 ))K context” else ctx_label=“” fi if [ -n “$model_name” ] && [ -n “$ctx_label” ]; then case “$model_name” in *(*context)) model_part=“$model_name}" ;; *) model_part=“${model_name} (${ctx_label})” ;; esac elif [ -n “$model_name” ]; then model_part=“${model_name}” else model_part=“” fi # ── Context window bar ──────────────────────────────────────────────────────── used_pct=$(echo “$input” jq -r ‘.context_window.used_percentage // empty’) if [ -n “$used_pct” ]; then used_int=$(printf ‘%.0f’ “$used_pct”) filled=$(( used_int / 10 )) empty=$(( 10 - filled )) bar=“” for i in $(seq 1 $filled); do bar="${bar█”; done for i in $(seq 1 $empty); do bar=“$bar}░“; done if [ “$used_int” -le 15 ]; then color=”$GREEN" elif [ “$used_int” -le 50 ]; then color=“$YELLOW” elif [ “$used_int” -le 75 ]; then color=“$ORANGE” else color=“$RED” fi ctx_bar_part=“${WHITE}[${RESET}${color}${bar}${RESET}${WHITE}]${RESET} ${color}${used_int}%${RESET}” else ctx_bar_part=“${WHITE}[${RESET}${GREEN}░░░░░░░░░░${RESET}${WHITE}]${RESET} ${GREEN}0%${RESET}” fi if [ -n “$model_part” ]; then model_colored=“${ORANGE}${model_part}${RESET}” ctx_part="${model_colored} ${ctx_bar_part” else ctx_part=“$ctx_bar_part” fi # ── Git branch ──────────────────────────────────────────────────────────────── branch_part=“” git_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) if [ -n “$git_branch” ]; then branch_part=" | branch:$CYAN}${git_branch}${RESET}" fi # ── Rate limits ─────────────────────────────────────────────────────────────── five=$(echo “$input” jq -r ‘.rate_limits.five_hour.used_percentage // empty’) week=$(echo “$input” | jq -r ‘.rate_limits.seven_day.used_percentage // empty’) _rate_color() { local pct pct=$(printf ‘%.0f’ “$1”) if [ “$pct” -le 74 ]; then printf ‘%s’ “$GREEN” elif [ “$pct” -le 82 ]; then printf ‘%s’ “$YELLOW” elif [ “$pct” -le 90 ]; then printf ‘%s’ “$ORANGE” else printf ‘%s’ “$RED” fi rate_part=“” if [ -n “$five” ] && [ -n “$week” ]; then five_int=$(printf ‘%.0f’ “$five”) week_int=$(printf ‘%.0f’ “$week”) five_color=$(_rate_color “$five”) week_color=$(_rate_color “$week”) rate_part=" | 5h:$five_color}${five_int}%${RESET} 7d:${week_color$week_int}%${RESET} " elif [ -n “$five” ]; then five_int=$(printf ‘%.0f’ “$five”) five_color=$(_rate_color “$five”) rate_part=" | 5h:${five_color$five_int}%${RESET} " elif [ -n “$week” ]; then week_int=$(printf ‘%.0f’ “$week”) week_color=$(_rate_color “$week”) rate_part=" | 7d:${week_color$week_int}%${RESET} " fi # ── Session time (from transcript creation time) ────────────────────────────── session_time_part=“” transcript_path=$(echo “$input” | jq -r ‘.transcript_path // empty’) if [ -n “$transcript_path” ] && [ -f “$transcript_path” ]; then if stat -f “%B” “$transcript_path” >/dev/null 2>&1; then birth=$(stat -f “%B” “$transcript_path” 2>/dev/null) else birth=$(stat -c “%W” “$transcript_path” 2>/dev/null) fi now=$(date +%s) if [ -n “$birth” ] && [ “$birth” -gt 0 ] 2>/dev/null; then elapsed=$(( now - birth )) hours=$(( elapsed / 3600 )) minutes=$(( (elapsed % 3600) / 60 )) session_time_part=" session:${YELLOW${hours}h${minutes}m${RESET}" fi fi # ── Output ──────────────────────────────────────────────────────────────────── printf ‘%b’ “${ctx_part}${branch_part}${rate_part}${session_time_part}” submitted by /u/Spiritual_Cycle_3263

Originally posted by u/Spiritual_Cycle_3263 on r/ClaudeCode