Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created June 10, 2026 01:01
Show Gist options
  • Select an option

  • Save bbrown/8f29a3e801add66d9a41244fe3586225 to your computer and use it in GitHub Desktop.

Select an option

Save bbrown/8f29a3e801add66d9a41244fe3586225 to your computer and use it in GitHub Desktop.
Current Claude /statusline
#!/bin/bash
input=$(cat)
# --- Colors (256-color, dimmed for terminal) ---
CYAN='\033[38;5;73m'
PURPLE='\033[38;5;103m'
GRAY='\033[38;5;243m'
WHITE='\033[38;5;252m'
GREEN='\033[38;5;107m'
BOLD_WHITE='\033[1;38;5;252m'
RESET='\033[0m'
# --- Extract fields ---
model_name=$(echo "$input" | jq -r '.model.display_name // "Unknown"')
thinking_level=$(echo "$input" | jq -r '.effort.level // (if .thinking.enabled then "on" else "off" end)')
used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // 0')
total_in=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
total_out=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
# Format used percentage to 1 decimal
used_pct_fmt=$(printf "%.1f" "$used_pct")
# Format total tokens (input+output) as human-readable (e.g. 60.0M)
total_tokens=$((total_in + total_out))
if [ "$total_tokens" -ge 1000000 ]; then
total_fmt=$(awk -v n="$total_tokens" 'BEGIN { printf "%.1fM", n/1000000 }')
elif [ "$total_tokens" -ge 1000 ]; then
total_fmt=$(awk -v n="$total_tokens" 'BEGIN { printf "%.1fK", n/1000 }')
else
total_fmt="${total_tokens}"
fi
# --- Cost estimation ---
# No direct cost field; approximate using Sonnet/Opus-class blended rate
# based on cache-aware token usage from current_usage if present.
input_tokens=$(echo "$input" | jq -r '.context_window.current_usage.input_tokens // 0')
output_tokens=$(echo "$input" | jq -r '.context_window.current_usage.output_tokens // 0')
cache_creation=$(echo "$input" | jq -r '.context_window.current_usage.cache_creation_input_tokens // 0')
cache_read=$(echo "$input" | jq -r '.context_window.current_usage.cache_read_input_tokens // 0')
# Rough Opus-class pricing per token (USD): input 15/M, output 75/M, cache write 18.75/M, cache read 1.5/M
cost=$(awk -v i="$input_tokens" -v o="$output_tokens" -v cw="$cache_creation" -v cr="$cache_read" \
'BEGIN { printf "%.2f", (i*15 + o*75 + cw*18.75 + cr*1.5) / 1000000 }')
# --- Rate limits ---
session_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
session_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
weekly_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
weekly_reset=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty')
now=$(date +%s)
format_duration() {
local secs=$1
if [ -z "$secs" ] || [ "$secs" -le 0 ] 2>/dev/null; then
echo "--"
return
fi
local days=$((secs / 86400))
local hours=$(((secs % 86400) / 3600))
local mins=$(((secs % 3600) / 60))
if [ "$days" -gt 0 ]; then
printf "%dd %dhr %dm" "$days" "$hours" "$mins"
else
printf "%dhr %dm" "$hours" "$mins"
fi
}
if [ -n "$session_pct" ]; then
session_pct_fmt=$(printf "%.1f" "$session_pct")
session_remain=$((session_reset - now))
session_reset_fmt=$(format_duration "$session_remain")
else
session_pct_fmt="--"
session_reset_fmt="--"
fi
if [ -n "$weekly_pct" ]; then
weekly_pct_fmt=$(printf "%.1f" "$weekly_pct")
weekly_remain=$((weekly_reset - now))
weekly_reset_fmt=$(format_duration "$weekly_remain")
else
weekly_pct_fmt="--"
weekly_reset_fmt="--"
fi
# --- Build line 1 ---
printf "${CYAN}Model:${RESET} ${CYAN}%s${RESET} ${GRAY}|${RESET} ${PURPLE}Thinking: %s${RESET} ${GRAY}|${RESET} ${WHITE}Ctx Used: %s%%${RESET} ${GRAY}|${RESET} ${GRAY}Total: %s${RESET} ${GRAY}|${RESET} ${WHITE}Cost:${RESET} ${GREEN}\$%s${RESET}\n" \
"$model_name" "$thinking_level" "$used_pct_fmt" "$total_fmt" "$cost"
# --- Build line 2 ---
printf "${WHITE}Session: %s%%${RESET} ${GRAY}|${RESET} ${WHITE}Reset: %s${RESET} ${GRAY}|${RESET} ${WHITE}Weekly: %s%%${RESET} ${GRAY}|${RESET} ${BOLD_WHITE}Weekly Reset: %s${RESET}\n" \
"$session_pct_fmt" "$session_reset_fmt" "$weekly_pct_fmt" "$weekly_reset_fmt"
@bbrown

bbrown commented Jun 10, 2026

Copy link
Copy Markdown
Author
  1. Store as ~/.claude/statusline-command.sh
  2. chmod 644 ~/.claude/statusline-command.sh
  3. Add the following to your ~/.claude/settings.json
{
	"statusLine": {
		"type": "command",
		"command": "bash ~/.claude/statusline-command.sh"
	}
}

@bbrown

bbrown commented Jun 10, 2026

Copy link
Copy Markdown
Author

Looks like this:
Screenshot 2026-06-09 at 18 15 39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment