Created
March 30, 2026 23:33
-
-
Save rightson/251ff3201e7df27f14763a12cbc9a735 to your computer and use it in GitHub Desktop.
~/.claude/statusline.sh
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
| #!/bin/bash | |
| # Claude Code Status Line β single jq call, no loops | |
| # Format: πΏ <branch> | π <folder> | <Model> [ββββββββ] ~XX% | π 5h XX% | π· vX.X.X | |
| # Single jq: parse all fields + build colored bar, tab-separated | |
| IFS=$'\t' read -r MODEL CWD PCT RATE_5H VERSION BAR RL_COLOR < <( | |
| jq -rj ' | |
| def bar: | |
| (.context_window.used_percentage // 0 | floor) as $pct | | |
| ($pct * 20 / 100 | if . > 20 then 20 elif . < 0 then 0 else . end | floor) as $filled | | |
| (if $pct < 20 then "\u001b[32m" | |
| elif $pct < 40 then "\u001b[36m" | |
| elif $pct < 60 then "\u001b[33m" | |
| elif $pct < 80 then "\u001b[31m" | |
| else "\u001b[35m" | |
| end) as $color | | |
| $color + ($filled * "β") + "\u001b[90m" + ((20 - $filled) * "β") + "\u001b[0m"; | |
| def rl_color: | |
| (.rate_limits.five_hour.used_percentage // 0 | floor) as $r | | |
| if $r >= 80 then "\u001b[31m" | |
| elif $r >= 50 then "\u001b[33m" | |
| else "\u001b[32m" | |
| end; | |
| [ | |
| (.model.display_name // "?"), | |
| (.cwd // ""), | |
| (.context_window.used_percentage // 0 | floor | tostring), | |
| (.rate_limits.five_hour.used_percentage // 0 | floor | tostring), | |
| (.version // "?"), | |
| bar, | |
| rl_color | |
| ] | join("\t") + "\n" | |
| ' | |
| ) | |
| # Git branch (cached 5s, single file) | |
| CACHE="/tmp/.claude-sl-cache" | |
| NOW=${EPOCHSECONDS:-$(printf '%(%s)T' -1 2>/dev/null || date +%s)} | |
| if [[ -f "$CACHE" ]]; then | |
| IFS=$'\t' read -r CACHED_TIME CACHED_DIR BRANCH < "$CACHE" | |
| if (( NOW - CACHED_TIME > 5 )) || [[ "$CACHED_DIR" != "$CWD" ]]; then | |
| BRANCH=$(git -C "$CWD" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "?") | |
| printf '%s\t%s\t%s' "$NOW" "$CWD" "$BRANCH" > "$CACHE" | |
| fi | |
| else | |
| BRANCH=$(git -C "$CWD" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "?") | |
| printf '%s\t%s\t%s' "$NOW" "$CWD" "$BRANCH" > "$CACHE" | |
| fi | |
| printf 'πΏ %s | π %s | %s [%b] ~%s%% | π %b5h %s%%\033[0m | π· v%s\n' \ | |
| "$BRANCH" "${CWD##*/}" "$MODEL" "$BAR" "$PCT" "$RL_COLOR" "$RATE_5H" "$VERSION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment