Created
June 21, 2026 09:38
-
-
Save AlbertoBarrago/8a94673716b9291b39365d799cc23768 to your computer and use it in GitHub Desktop.
Claude Code statusline — project · branch · ctx% · 5h% · 7d%
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 status line — Matrix green theme | |
| input=$(cat) | |
| # ── ANSI palette ───────────────────────────────────────────────────────────── | |
| RESET='\033[0m' | |
| DIM='\033[2m' | |
| BLUE_NIGHT='\033[38;5;75m' | |
| GREEN_BRIGHT='\033[38;5;82m' | |
| GREEN_MID='\033[38;5;40m' | |
| YELLOW='\033[38;5;226m' | |
| ORANGE='\033[38;5;214m' | |
| RED='\033[38;5;196m' | |
| CYAN_DIM='\033[38;5;36m' | |
| SEP="${CYAN_DIM}|${RESET}" | |
| # ── Color by used % (higher = warmer) ──────────────────────────────────────── | |
| color_by_used() { | |
| local pct="$1" | |
| if [ -z "$pct" ]; then printf '%s' "$GREEN_MID"; return; fi | |
| local i=${pct%.*} | |
| if [ "$i" -lt 40 ]; then printf '%s' "$GREEN_BRIGHT" | |
| elif [ "$i" -lt 65 ]; then printf '%s' "$YELLOW" | |
| elif [ "$i" -lt 85 ]; then printf '%s' "$ORANGE" | |
| else printf '%s' "$RED" | |
| fi | |
| } | |
| # ── Parse fields ────────────────────────────────────────────────────────────── | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty') | |
| project_dir=$(echo "$input" | jq -r '.workspace.project_dir // empty') | |
| project_name="" | |
| if [ -n "$project_dir" ]; then | |
| project_name=$(basename "$project_dir") | |
| fi | |
| git_branch="" | |
| if [ -n "$cwd" ]; then | |
| git_branch=$(git -C "$cwd" --no-optional-locks rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| fi | |
| ctx_used=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| five_used=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty') | |
| five_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty') | |
| week_used=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') | |
| week_reset=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty') | |
| # ── Format time until reset ────────────────────────────────────────────────── | |
| fmt_reset() { | |
| local epoch="$1" | |
| [ -z "$epoch" ] && return | |
| local now diff | |
| now=$(date +%s) | |
| diff=$(( epoch - now )) | |
| [ "$diff" -le 0 ] && return | |
| if [ "$diff" -ge 86400 ]; then | |
| printf '%dd' $(( diff / 86400 )) | |
| elif [ "$diff" -ge 3600 ]; then | |
| printf '%dh' $(( diff / 3600 )) | |
| else | |
| printf '%dm' $(( diff / 60 )) | |
| fi | |
| } | |
| # ── Build parts ─────────────────────────────────────────────────────────────── | |
| parts=() | |
| # project root | |
| if [ -n "$project_name" ]; then | |
| parts+=("$(printf '%b%s%b' "$BLUE_NIGHT" " $project_name" "$RESET")") | |
| fi | |
| # git branch | |
| if [ -n "$git_branch" ]; then | |
| parts+=("$(printf '%b%s%b' "$RED" "$git_branch" "$RESET")") | |
| fi | |
| # ctx (context window used%) | |
| if [ -n "$ctx_used" ]; then | |
| col=$(color_by_used "$ctx_used") | |
| ctx_int=${ctx_used%.*} | |
| parts+=("$(printf '%bctx %b%s%b' "$DIM" "$col" "${ctx_int}%" "$RESET")") | |
| fi | |
| # 5h used% | |
| if [ -n "$five_used" ]; then | |
| col=$(color_by_used "$five_used") | |
| five_int=${five_used%.*} | |
| parts+=("$(printf '%b5h %b%s%b' "$DIM" "$col" "${five_int}%" "$RESET")") | |
| fi | |
| # 7d used% | |
| if [ -n "$week_used" ]; then | |
| col=$(color_by_used "$week_used") | |
| week_int=${week_used%.*} | |
| parts+=("$(printf '%b7d %b%s%b' "$DIM" "$col" "${week_int}%" "$RESET")") | |
| fi | |
| # ── Join ────────────────────────────────────────────────────────────────────── | |
| output="" | |
| for i in "${!parts[@]}"; do | |
| if [ "$i" -eq 0 ]; then | |
| output="${parts[$i]}" | |
| else | |
| output="${output} $(printf '%b' "$SEP") ${parts[$i]}" | |
| fi | |
| done | |
| printf '%b%s%b\n' "" "$output" "$RESET" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation
Then add (or merge) this in
~/.claude/settings.json:{ "statusLine": { "command": "bash ~/.claude/statusline-command.sh" } }Requires
jqandgitin PATH.