Last active
June 19, 2026 08:38
-
-
Save miZyind/1877b3e88f147b1f4899b83258a201e4 to your computer and use it in GitHub Desktop.
Claude Code Statusline
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
| * | |
| !.gitignore | |
| !statusline-command.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
| { | |
| "permissions": { | |
| "allow": [ | |
| "mcp__figma", | |
| "mcp__figma-rest", | |
| "mcp__playwright", | |
| "mcp__claude_ai_Canva", | |
| "Skill(grill-me)", | |
| "Skill(webwright:webwright)", | |
| "Bash(cd *)", | |
| "Bash(ls *)", | |
| "Bash(sed *)", | |
| "Bash(find *)", | |
| "Bash(lsof *)", | |
| "Bash(grep *)", | |
| "Bash(xargs *)", | |
| "Bash(git add *)", | |
| "Bash(git commit *)", | |
| "Bash(git push *)", | |
| "Bash(npm view *)", | |
| "Bash(npx wrangler *)", | |
| "Bash(openspec *)", | |
| "Bash(docker compose *)", | |
| "Bash(docker exec *)", | |
| "Read(//tmp/**)", | |
| "Read(//private/tmp/**)", | |
| "Write(//tmp/**)", | |
| "Write(//private/tmp/**)", | |
| "Edit(//tmp/**)", | |
| "Edit(//private/tmp/**)", | |
| "Read(//Users/jz/.playwright-mcp/**)" | |
| ] | |
| }, | |
| "model": "opus[1m]", | |
| "statusLine": { | |
| "type": "command", | |
| "command": "~/.claude/statusline-command.sh" | |
| }, | |
| "enabledPlugins": { | |
| "rust-analyzer-lsp@claude-plugins-official": true, | |
| "frontend-design@claude-plugins-official": true, | |
| "claude-md-management@claude-plugins-official": true, | |
| "webwright@webwright": true | |
| }, | |
| "extraKnownMarketplaces": { | |
| "webwright": { | |
| "source": { | |
| "source": "github", | |
| "repo": "microsoft/Webwright" | |
| } | |
| } | |
| }, | |
| "language": "traditional-chinese", | |
| "alwaysThinkingEnabled": false, | |
| "effortLevel": "xhigh", | |
| "skipWorkflowUsageWarning": true | |
| } |
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/zsh | |
| input=$(cat) | |
| # CWD: ~/.claude/statusline-command.sh | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // ""') | |
| # Model Name: claude-opus-4-7 -> Opus 4.7, claude-haiku-4-5-20251001 -> Haiku 4.5 | |
| model=$(echo "$input" | jq -r 'try (.model.id // "" | sub("^claude-"; "") | sub("\\[[^]]*\\]$"; "") | sub("-[0-9]{8}$"; "") | split("-") | "\(.[0][0:1] | ascii_upcase)\(.[0][1:]) \(.[1:] | join("."))") catch ""') | |
| # Context, Rate Limit Percentage: 50% | |
| ctx_pct=$(echo "$input" | jq -r '(.context_window.used_percentage // 0) | round') | |
| # Rate limits are absent from the payload until the first API response of a session | |
| # (e.g. right after resume) — cache the last seen values and fall back to them, | |
| # dropping any window whose resets_at is already in the past. | |
| RL_CACHE="$HOME/.claude/statusline-rate-limits.json" | |
| rl=$(echo "$input" | jq -c '.rate_limits // empty') | |
| if [ -n "$rl" ]; then | |
| printf '%s' "$rl" > "$RL_CACHE" | |
| elif [ -r "$RL_CACHE" ]; then | |
| rl=$(jq -c --argjson now "$(date +%s)" 'with_entries(select((.value.resets_at // 0) > $now))' "$RL_CACHE" 2>/dev/null) | |
| fi | |
| five_pct=$(echo "$rl" | jq -r '(.five_hour.used_percentage // empty) | round') | |
| seven_pct=$(echo "$rl" | jq -r '(.seven_day.used_percentage // empty) | round') | |
| # Context Window Size: 200000 -> 200K, 1000000 -> 1M | |
| ctx_size=$(echo "$input" | jq -r '(.context_window.context_window_size // empty) | if . >= 1000000 then "\((. / 1000000) | floor)M" elif . >= 1000 then "\((. / 1000) | floor)K" else tostring end') | |
| # Rate Limit (5h, 7d): 1738425600 - 2025-02-01T04:00:00Z | |
| five_resets=$(echo "$rl" | jq -r '.five_hour.resets_at // empty') | |
| seven_resets=$(echo "$rl" | jq -r '.seven_day.resets_at // empty') | |
| # ANSI Palette | |
| BG_GRAY=$'\033[48;5;236m' #303030 | |
| FG_WHITE=$'\033[38;5;231m' #ffffff | |
| FG_DARK=$'\033[38;5;16m' #000000 | |
| BG_BLUE=$'\033[48;5;4m' #000080 | |
| BG_PURPLE=$'\033[48;5;54m' #5f0087 | |
| BG_BROWN=$'\033[48;5;94m' #875f00 | |
| FG_GREEN=$'\033[38;5;35m' #00af5f | |
| FG_YELLOW=$'\033[38;5;226m' #ffff00 | |
| FG_BROWN=$'\033[38;5;130m' #af5f00 | |
| FG_RED=$'\033[38;5;160m' #d70000 | |
| # ANSI Style | |
| R=$'\033[0m' # Reset | |
| # CWD Segment | |
| CWD_ICON=$'\uf07c' # | |
| CWD_SEG="${BG_BLUE}${FG_WHITE} ${CWD_ICON} ${cwd/#$HOME/~} ${R}" | |
| # Git Segment | |
| if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then | |
| GIT_ICONS=$'\uf1d3 \uf126' # | |
| # Get branch name: main | |
| branch=$(git -C "$cwd" branch --show-current 2>/dev/null) | |
| [ -z "$branch" ] && branch=$(git -C "$cwd" rev-parse --short HEAD 2>/dev/null) | |
| # Choose color: green/yellow for based on status | |
| if [ "$(git -C "$cwd" status --porcelain 2>/dev/null | wc -l | tr -d ' ')" -gt 0 ]; then | |
| GIT_COLORS="${FG_YELLOW/38;5;/48;5;}${FG_DARK}" | |
| else | |
| GIT_COLORS="${FG_GREEN/38;5;/48;5;}${FG_DARK}" | |
| fi | |
| GIT_SEG="${GIT_COLORS} ${GIT_ICONS} ${branch} ${R}" | |
| fi | |
| # Progress Bar | |
| bar() { | |
| local PCT=$1 LABEL=$2 | |
| [ -z "$PCT" ] && return | |
| local ICON=$'\uf254' # | |
| local FG_BAR=$FG_GREEN BG_LABEL=$BG_PURPLE BAR_WIDTH=10 SEP=$'\ue0b0' | |
| if [[ "$LABEL" =~ ^[0-9]+$ ]]; then | |
| ICON=$'\uf021' # | |
| BG_LABEL=$BG_BROWN | |
| LABEL=$(LC_TIME=C date -j -r "$LABEL" "+%m-%d (%a) %I%p" | sed 's/) 0/) /') | |
| fi | |
| local PREFIX="${BG_LABEL}${FG_WHITE} ${ICON} ${LABEL} ${R}" | |
| if (( PCT >= 80 )); then FG_BAR=$FG_RED | |
| elif (( PCT >= 60 )); then FG_BAR=$FG_BROWN | |
| elif (( PCT >= 40 )); then FG_BAR=$FG_YELLOW | |
| fi | |
| local BG=${FG_BAR/38;5;/48;5;}; | |
| local FG=${BG_LABEL/48;5;/38;5;}; | |
| if (( PCT == 0 )) then SEP="" fi | |
| local filled=$((PCT * BAR_WIDTH / 100)) | |
| local empty=$((BAR_WIDTH - filled)) | |
| [ "$filled" -gt 0 ] && printf -v FILL "%${filled}s" && BAR="${FILL// /█}" | |
| [ "$empty" -gt 0 ] && printf -v PAD "%${empty}s" && BAR="${BAR}${PAD// /░}" | |
| printf '%s' "${PREFIX}${BG}${FG}${SEP}${BG_GRAY}${FG_BAR}${BAR}${BG_LABEL} ${PCT}% ${R}" | |
| } | |
| CTX_SEG=$(bar "$ctx_pct" "${model} ${ctx_size}") | |
| FIVE_SEG=$(bar "$five_pct" "$five_resets") | |
| SEVEN_SEG=$(bar "$seven_pct" "$seven_resets") | |
| # Black powerline thin separator between the 5h and weekly usage bars | |
| # (U+E0B1 — same Nerd Font family as the bar separators, so it sits exactly at cell height and never overflows the row) | |
| SEP_BAR=$'\033[48;5;0m\033[38;5;240m\033[0m' | |
| # Output | |
| printf '%s' "${CWD_SEG}${GIT_SEG}${CTX_SEG}${FIVE_SEG}${SEP_BAR}${SEVEN_SEG}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment