Last active
March 17, 2026 19:40
-
-
Save whomwah/b6d4437c23e7d76cd041fc993d4e3398 to your computer and use it in GitHub Desktop.
A nice status line for Claude Code
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
| Opus 4.6 (1M context) | Talk | main | ▄░░░░░░░░░ 3% of 1000k tokens |
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 | |
| # Color codes (blue) | |
| C_RESET='\033[0m' | |
| C_GRAY='\033[38;5;245m' | |
| C_BAR_EMPTY='\033[38;5;238m' | |
| C_ACCENT='\033[38;5;74m' | |
| input=$(cat) | |
| # Extract all fields in a single jq call | |
| { read -r model; read -r cwd; read -r transcript_path; read -r max_context; } < <( | |
| jq -r ' | |
| (.model.display_name // .model.id // "?"), | |
| (.cwd // ""), | |
| (.transcript_path // ""), | |
| (.context_window.context_window_size // 200000) | |
| ' <<< "$input" | |
| ) | |
| dir=$(basename "$cwd" 2>/dev/null || echo "?") | |
| max_k=$((max_context / 1000)) | |
| # Get git branch | |
| branch="" | |
| if [[ -n "$cwd" && -d "$cwd" ]]; then | |
| branch=$(git -C "$cwd" branch --show-current 2>/dev/null) | |
| fi | |
| # Calculate context percentage | |
| # 20k baseline: includes system prompt (~3k), tools (~15k), memory (~300), | |
| # plus ~2k for git status, env block, XML framing, and other dynamic context | |
| baseline=20000 | |
| if [[ -n "$transcript_path" && -f "$transcript_path" ]]; then | |
| context_length=$(jq -s ' | |
| map(select(.message.usage and .isSidechain != true and .isApiErrorMessage != true)) | | |
| last | | |
| if . then | |
| (.message.usage.input_tokens // 0) + | |
| (.message.usage.cache_read_input_tokens // 0) + | |
| (.message.usage.cache_creation_input_tokens // 0) | |
| else 0 end | |
| ' < "$transcript_path") | |
| if [[ "$context_length" -gt 0 ]]; then | |
| pct=$((context_length * 100 / max_context)) | |
| pct_prefix="" | |
| else | |
| pct=$((baseline * 100 / max_context)) | |
| pct_prefix="~" | |
| fi | |
| else | |
| pct=$((baseline * 100 / max_context)) | |
| pct_prefix="~" | |
| fi | |
| [[ $pct -gt 100 ]] && pct=100 | |
| # Build context bar | |
| bar="" | |
| for ((i=0; i<10; i++)); do | |
| progress=$((pct - i * 10)) | |
| if [[ $progress -ge 8 ]]; then | |
| bar+="${C_ACCENT}█${C_RESET}" | |
| elif [[ $progress -ge 3 ]]; then | |
| bar+="${C_ACCENT}▄${C_RESET}" | |
| else | |
| bar+="${C_BAR_EMPTY}░${C_RESET}" | |
| fi | |
| done | |
| # Build output: Model | Dir | Branch | Context | |
| output="${C_ACCENT}${model}${C_GRAY} | ${dir}" | |
| [[ -n "$branch" ]] && output+=" | ${branch}" | |
| output+=" | ${bar} ${C_GRAY}${pct_prefix}${pct}% of ${max_k}k tokens${C_RESET}" | |
| printf '%b\n' "$output" |
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
| { | |
| "statusLine": { | |
| "type": "command", | |
| "command": "~/.claude/scripts/context-bar.sh" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment