Created
March 28, 2026 08:52
-
-
Save mikaturunen/784c3eedb2f808c610d15b971b8c97b3 to your computer and use it in GitHub Desktop.
Claude Code active status line — dark theme (model · git · EUR cost · context · rate limits)
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
| #!/usr/bin/env bash | |
| # Claude Code Statusline — dark theme | |
| # https://gist.github.com/mikaturunen/784c3eedb2f808c610d15b971b8c97b3 | |
| # | |
| # Shows: model · git branch · cost in EUR · context remaining | |
| # rate limits: 5-hour and 7-day windows (Claude.ai subscribers only) | |
| # | |
| # ── INSTALL ─────────────────────────────────────────────────────────────────── | |
| # | |
| # 1. Download the script: | |
| # | |
| # curl -fsSL https://gist.githubusercontent.com/mikaturunen/784c3eedb2f808c610d15b971b8c97b3/raw/statusline.sh \ | |
| # -o ~/.claude/statusline.sh && chmod +x ~/.claude/statusline.sh | |
| # | |
| # 2. Add to ~/.claude/settings.json (create the file if it doesn't exist): | |
| # | |
| # { | |
| # "statusLine": { | |
| # "type": "command", | |
| # "command": "~/.claude/statusline.sh" | |
| # } | |
| # } | |
| # | |
| # If you already have a settings.json, add just the "statusLine" key | |
| # alongside your existing keys. | |
| # | |
| # 3. Restart Claude Code — the statusline appears immediately. | |
| # | |
| # Requirements: bash, jq, git, awk (all standard on macOS and Linux) | |
| # | |
| # ── CONFIGURATION ───────────────────────────────────────────────────────────── | |
| # | |
| # EUR_RATE — adjust to the current USD→EUR rate (check xe.com) | |
| # | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| EUR_RATE=0.92 | |
| # --- Base colors --- | |
| RESET='\033[0m' | |
| BOLD='\033[1m' | |
| DIM='\033[2m' | |
| CYAN='\033[96m' # model name | |
| GREEN='\033[92m' # git branch | |
| YELLOW='\033[93m' # dirty marker + € symbol | |
| GOLD='\033[33m' # cost value | |
| # --- 5-step palette used for both context and rate limits --- | |
| # Applied to "used %" (0=great, 100=bad) | |
| C1='\033[92m' # green ≤20% used | |
| C2='\033[38;5;154m' # yellow-green 21-40% | |
| C3='\033[93m' # yellow 41-60% | |
| C4='\033[38;5;208m' # orange 61-80% | |
| C5='\033[91m' # red >80% | |
| # Return one of the 5 palette colors for a given used-percentage | |
| pct_color() { | |
| local pct=${1%%.*} # strip decimals | |
| if [ "$pct" -le 20 ]; then printf '%b' "$C1" | |
| elif [ "$pct" -le 40 ]; then printf '%b' "$C2" | |
| elif [ "$pct" -le 60 ]; then printf '%b' "$C3" | |
| elif [ "$pct" -le 80 ]; then printf '%b' "$C4" | |
| else printf '%b' "$C5" | |
| fi | |
| } | |
| # Build a 10-block bar colored by used-percentage | |
| make_bar() { | |
| local used=${1%%.*} | |
| local color | |
| color=$(pct_color "$used") | |
| local filled=$(( used * 10 / 100 )) | |
| local empty=$(( 10 - filled )) | |
| local bar="" | |
| for (( i=0; i<filled; i++ )); do bar+="▓"; done | |
| for (( i=0; i<empty; i++ )); do bar+="░"; done | |
| printf '%b%s%b' "$color" "$bar" "$RESET" | |
| } | |
| # --- Read and parse stdin JSON --- | |
| INPUT=$(cat) | |
| MODEL=$(printf '%s' "$INPUT" | jq -r '.model.id // "unknown"') | |
| COST_USD=$(printf '%s' "$INPUT" | jq -r '.cost.total_cost_usd // 0') | |
| CTX_USED=$(printf '%s' "$INPUT" | jq -r '.context_window.used_percentage // 0') | |
| CWD=$(printf '%s' "$INPUT" | jq -r '.workspace.current_dir // empty') | |
| RATE_5H=$(printf '%s' "$INPUT" | jq -r '.rate_limits.five_hour.used_percentage // empty') | |
| RATE_7D=$(printf '%s' "$INPUT" | jq -r '.rate_limits.seven_day.used_percentage // empty') | |
| CTX_USED=${CTX_USED%%.*} | |
| CTX_REMAINING=$(( 100 - CTX_USED )) | |
| # --- EUR conversion --- | |
| COST_EUR=$(awk -v cost="$COST_USD" -v rate="$EUR_RATE" 'BEGIN { printf "%.2f", cost * rate }') | |
| # --- Git branch + dirty flag --- | |
| BRANCH="" | |
| DIRTY="" | |
| if [ -n "$CWD" ] && cd "$CWD" 2>/dev/null; then | |
| BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| [ -n "$(git status --porcelain 2>/dev/null)" ] && DIRTY=" ●" | |
| fi | |
| # ── Line 1: model · branch · cost · context ────────────────────────────────── | |
| CTX_COLOR=$(pct_color "$CTX_USED") | |
| CTX_BAR=$(make_bar "$CTX_USED") | |
| LINE1="${CYAN}${BOLD}◆ ${MODEL}${RESET}" | |
| [ -n "$BRANCH" ] && LINE1+=" ${GREEN}${BRANCH}${YELLOW}${DIRTY}${RESET}" | |
| LINE1+=" ${YELLOW}€${GOLD}${COST_EUR}${RESET}" | |
| LINE1+=" ${CTX_BAR} ${CTX_COLOR}${CTX_REMAINING}% ctx left${RESET}" | |
| printf "%b\n" "$LINE1" | |
| # ── Line 2: rate limits (only when data is available) ──────────────────────── | |
| if [ -n "$RATE_5H" ] || [ -n "$RATE_7D" ]; then | |
| LINE2="${DIM}rate limits:${RESET}" | |
| if [ -n "$RATE_5H" ]; then | |
| RATE_5H_INT=${RATE_5H%%.*} | |
| COLOR_5H=$(pct_color "$RATE_5H_INT") | |
| BAR_5H=$(make_bar "$RATE_5H_INT") | |
| LINE2+=" ${DIM}5h${RESET} ${BAR_5H} ${COLOR_5H}${RATE_5H_INT}% used${RESET}" | |
| fi | |
| if [ -n "$RATE_5H" ] && [ -n "$RATE_7D" ]; then | |
| LINE2+=" ${DIM}│${RESET}" | |
| fi | |
| if [ -n "$RATE_7D" ]; then | |
| RATE_7D_INT=${RATE_7D%%.*} | |
| COLOR_7D=$(pct_color "$RATE_7D_INT") | |
| BAR_7D=$(make_bar "$RATE_7D_INT") | |
| LINE2+=" ${DIM}7d${RESET} ${BAR_7D} ${COLOR_7D}${RATE_7D_INT}% used${RESET}" | |
| fi | |
| printf "%b\n" "$LINE2" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment