-
Notifications
You must be signed in to change notification settings - Fork 1
Add visual status line for Claude Code #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e599d5
Add status line
tyom c26ebee
Add visual context bar and documentation to status line
tyom 13b9834
Fix progress bar edge cases and clarify color thresholds
tyom 98c0c4f
Show effective context usage against 77.5% auto-compact threshold
tyom 5e24dd7
Add jq dependency check and documentation
tyom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Claude Code Dotfiles Plugin | ||
|
|
||
| Personal development workflow automation - hooks, tools, and configurations. | ||
|
|
||
| ## Status Line | ||
|
|
||
| A custom status bar showing model name and context usage with a visual progress bar. | ||
|
|
||
| Requires: `jq` | ||
|
|
||
| ### Enable | ||
|
|
||
| Add to `~/.claude/settings.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "statusLine": { | ||
| "type": "command", | ||
| "command": "~/Code/dotfiles/claude-plugin/statusline/statusline.sh", | ||
| "padding": 0 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Output | ||
|
|
||
| ```text | ||
| Opus 4.5 | ctx ■■■■■□□□□□□□□□□▨▨▨▨▨ 33% | ||
| ``` | ||
|
|
||
| The bar shows 15 usable squares plus 5 reserved squares (▨) representing the 22.5% auto-compact buffer. The percentage shown is the **effective usage** against the usable 77.5% of context (e.g., 25% total context = 32% effective). | ||
|
|
||
| Colors change based on effective usage: | ||
|
|
||
| - Grey: < 75% (~58% total) | ||
| - Orange: 75–93% (~58–72% total) | ||
| - Red: ≥ 94% (~73%+ total) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Requires: jq | ||
| if ! command -v jq &>/dev/null; then | ||
| echo "statusline: jq required" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Read JSON input from stdin | ||
| input=$(cat) | ||
|
|
||
| # Extract context stats using jq | ||
| USED_PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0') | ||
| MODEL=$(echo "$input" | jq -r '.model.display_name // .model // "unknown"') | ||
|
|
||
| # Don't show anything for 0% | ||
| if (( $(echo "$USED_PCT == 0" | bc -l) )); then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Auto-compact threshold is 77.5% (22.5% buffer) | ||
| # Calculate effective percentage against the 77.5% threshold | ||
| EFFECTIVE_PCT=$(echo "scale=2; $USED_PCT / 77.5 * 100" | bc -l) | ||
| if (( $(echo "$EFFECTIVE_PCT > 100" | bc -l) )); then | ||
| EFFECTIVE_PCT=100 | ||
| fi | ||
|
|
||
| # Clamp raw percentage to 0-77.5 range (usable portion) | ||
| CLAMPED_PCT=$(echo "if ($USED_PCT < 0) 0 else if ($USED_PCT > 77.5) 77.5 else $USED_PCT" | bc -l) | ||
|
|
||
| # Build progress bar: 15 usable squares (75%) + 5 reserved squares (25%) | ||
| # Each square = 5% of total context | ||
| FULL_SQUARES=$(echo "scale=0; $CLAMPED_PCT / 5" | bc) | ||
| if [ "$FULL_SQUARES" -gt 15 ]; then | ||
| FULL_SQUARES=15 | ||
| fi | ||
|
|
||
| REMAINDER=$(echo "scale=1; $CLAMPED_PCT - ($FULL_SQUARES * 5)" | bc) | ||
| if [ "$FULL_SQUARES" -lt 15 ] && (( $(echo "$REMAINDER >= 2.5" | bc -l) )); then | ||
| HAS_HALF=1 | ||
| else | ||
| HAS_HALF=0 | ||
| fi | ||
|
|
||
| HALF_COUNT=$((HAS_HALF)) | ||
| EMPTY_SQUARES=$((15 - FULL_SQUARES - HALF_COUNT)) | ||
| if [ "$EMPTY_SQUARES" -lt 0 ]; then | ||
| EMPTY_SQUARES=0 | ||
| fi | ||
|
|
||
| BAR="" | ||
| for ((i=0; i<FULL_SQUARES; i++)); do | ||
| BAR+="■" | ||
| done | ||
| if [ "$HAS_HALF" -eq 1 ]; then | ||
| BAR+="◧" | ||
| fi | ||
| for ((i=0; i<EMPTY_SQUARES; i++)); do | ||
| BAR+="□" | ||
| done | ||
|
|
||
| # Color based on effective usage (grey < 75%, orange 75-94%, red >= 94%) | ||
| # These thresholds correspond to 60%/75%/80% of total context | ||
| if (( $(echo "$EFFECTIVE_PCT < 75" | bc -l) )); then | ||
| COLOR="\033[90m" # Grey | ||
| elif (( $(echo "$EFFECTIVE_PCT < 94" | bc -l) )); then | ||
| COLOR="\033[38;5;208m" # Orange (75% effective = 60% total) | ||
| else | ||
| COLOR="\033[31m" # Red (94% effective ≈ 75% total, near limit) | ||
| fi | ||
| RESET="\033[0m" | ||
| DARK_GRAY="\033[38;5;240m" # Dark gray for reserved blocks | ||
|
|
||
| # Output: Opus 4.5 | ctx ■■■■■■■■■■■■■■□▨▨▨▨▨ 89% | ||
| printf "%s | ctx ${COLOR}%s${DARK_GRAY}▨▨▨▨▨${COLOR} %.0f%%${RESET}" "$MODEL" "$BAR" "$EFFECTIVE_PCT" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.