Created
January 27, 2026 02:23
-
-
Save gastonmorixe/23927493f2eec0afdd49b6f70494984e to your computer and use it in GitHub Desktop.
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 fish | |
| # ============================================================================== | |
| # Claude Code Status Line Configuration | |
| # ============================================================================== | |
| # | |
| # This script customizes the Claude Code status bar to display contextual | |
| # session information at the bottom of the interface. | |
| # | |
| # ## What This Shows | |
| # | |
| # [Model] [SessionID] π directory | π° $cost | Context: X% | |
| # | |
| # Example output: | |
| # [Opus] [a3f1b2c4] π ghee-mail | π° $0.0123 | Context: 12% | |
| # | |
| # ## Components | |
| # | |
| # - **Model**: Display name (Opus, Sonnet, Haiku) | |
| # - **SessionID**: First 8 characters of unique session identifier | |
| # - **Directory**: Current working directory basename | |
| # - **Cost**: Total session cost in USD | |
| # - **Context**: Percentage of context window used | |
| # | |
| # ## Setup | |
| # | |
| # 1. Make this script executable: | |
| # chmod +x ~/.claude/statusline.sh | |
| # | |
| # 2. Add to ~/.claude/settings.json: | |
| # { | |
| # "statusLine": { | |
| # "type": "command", | |
| # "command": "~/.claude/statusline.sh", | |
| # "padding": 0 | |
| # } | |
| # } | |
| # | |
| # 3. Restart Claude Code | |
| # | |
| # ## Available Data Fields | |
| # | |
| # Claude Code provides this JSON structure via stdin: | |
| # | |
| # { | |
| # "session_id": "abc123...", // Unique session identifier | |
| # "model": { | |
| # "id": "claude-opus-4-1", | |
| # "display_name": "Opus" // Short model name | |
| # }, | |
| # "workspace": { | |
| # "current_dir": "/current/working/directory", | |
| # "project_dir": "/original/project/directory" | |
| # }, | |
| # "version": "1.0.80", // Claude Code version | |
| # "cost": { | |
| # "total_cost_usd": 0.01234, | |
| # "total_duration_ms": 45000, | |
| # "total_api_duration_ms": 2300, | |
| # "total_lines_added": 156, | |
| # "total_lines_removed": 23 | |
| # }, | |
| # "context_window": { | |
| # "total_input_tokens": 15234, | |
| # "total_output_tokens": 4521, | |
| # "context_window_size": 200000 | |
| # }, | |
| # "output_style": { | |
| # "name": "default" | |
| # } | |
| # } | |
| # | |
| # ## Customization Examples | |
| # | |
| # ### Add Git Branch | |
| # | |
| # set -l git_branch "" | |
| # if git rev-parse --git-dir >/dev/null 2>&1 | |
| # set git_branch " | πΏ "(git branch --show-current 2>/dev/null) | |
| # end | |
| # printf "...$git_branch" | |
| # | |
| # ### Show Lines Modified | |
| # | |
| # set -l lines_added (echo $input | jq -r '.cost.total_lines_added') | |
| # set -l lines_removed (echo $input | jq -r '.cost.total_lines_removed') | |
| # printf "... | +$lines_added -$lines_removed" | |
| # | |
| # ### Show Version | |
| # | |
| # set -l version (echo $input | jq -r '.version') | |
| # printf "... | v$version" | |
| # | |
| # ### Change Colors | |
| # | |
| # ANSI color codes: | |
| # \033[0;31m = red | |
| # \033[0;32m = green | |
| # \033[0;33m = yellow | |
| # \033[0;34m = blue | |
| # \033[0;35m = magenta | |
| # \033[0;36m = cyan | |
| # \033[0m = reset | |
| # | |
| # ## Testing | |
| # | |
| # Test this script manually: | |
| # | |
| # echo '{"session_id":"abc123def456","model":{"display_name":"Opus"},"workspace":{"current_dir":"/Users/gaston/project"},"cost":{"total_cost_usd":0.0123},"context_window":{"total_input_tokens":15000,"total_output_tokens":5000,"context_window_size":200000}}' | ~/.claude/statusline.sh | |
| # | |
| # Expected output: | |
| # [Opus] [abc123de] π project | π° $0.0123 | Context: 10% | |
| # | |
| # ## Troubleshooting | |
| # | |
| # - Status line doesn't appear | |
| # β Check script is executable: ls -l ~/.claude/statusline.sh | |
| # | |
| # - JSON parsing errors | |
| # β Ensure jq is installed: brew install jq | |
| # | |
| # - Colors not showing | |
| # β Test ANSI support: echo -e "\033[0;36mTest\033[0m" | |
| # | |
| # ============================================================================== | |
| # Read JSON from stdin | |
| set -l input (cat) | |
| # Extract values using jq | |
| set -l model (echo $input | jq -r '.model.display_name') | |
| set -l session_id (echo $input | jq -r '.session_id' | string sub -l 8) | |
| set -l current_dir (echo $input | jq -r '.workspace.current_dir' | path basename) | |
| set -l cost (echo $input | jq -r '.cost.total_cost_usd') | |
| # Context window usage | |
| set -l input_tokens (echo $input | jq -r '.context_window.total_input_tokens') | |
| set -l output_tokens (echo $input | jq -r '.context_window.total_output_tokens') | |
| set -l context_size (echo $input | jq -r '.context_window.context_window_size') | |
| set -l total_tokens (math $input_tokens + $output_tokens) | |
| set -l percent_used (math "round($total_tokens * 100 / $context_size)") | |
| # ANSI color codes | |
| set -l cyan (printf '\033[0;36m') | |
| set -l green (printf '\033[0;32m') | |
| set -l yellow (printf '\033[0;33m') | |
| set -l reset (printf '\033[0m') | |
| # Build and output status line | |
| printf "%s[%s]%s [%s%s%s] π %s | π° \$%.4f | %sContext: %s%%%s" \ | |
| $cyan $model $reset $yellow $session_id $reset $current_dir $cost $green $percent_used $reset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment