Created
May 25, 2026 12:22
-
-
Save fabienjuif/1bd6d133fd43c0c82305c13068228f04 to your computer and use it in GitHub Desktop.
Claude Code | Status line
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
| Example render | |
| --- | |
| Migrate CircleCI deploy job to GitHub Actions | ~/w/c/e/r/backend | [main] | 5h:2% 7d:4% |
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": "fish ~/.claude/statusline.fish" | |
| }, | |
| } |
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 | |
| set input (cat) | |
| # 1. Session description (up to 50 chars) | |
| set session_name (echo $input | jq -r '.session_name // empty') | |
| if test -n "$session_name" | |
| set desc (string sub -l 50 -- $session_name) | |
| else | |
| set desc (string sub -l 50 -- (echo $input | jq -r '.session_id // ""')) | |
| end | |
| # 2. Current directory (fish-style: ~/w/c/e/r/backend) | |
| set cwd (echo $input | jq -r '.workspace.current_dir // .cwd // ""') | |
| set cwd_tilde (string replace -r "^$HOME" "~" -- $cwd) | |
| # Shorten each intermediate component to its first character | |
| set parts (string split "/" -- $cwd_tilde) | |
| set n (count $parts) | |
| set short_parts | |
| for i in (seq 1 $n) | |
| if test $i -lt $n | |
| set short_parts $short_parts (string sub -l 1 -- $parts[$i]) | |
| else | |
| set short_parts $short_parts $parts[$i] | |
| end | |
| end | |
| set short_cwd (string join "/" -- $short_parts) | |
| # 3. Git branch (if in a git repo) | |
| set branch "" | |
| if test -n "$cwd" -a -d "$cwd" | |
| set branch (git -C $cwd branch --show-current 2>/dev/null) | |
| end | |
| # 4. Rate limits in 5h/7d format | |
| set five_pct (echo $input | jq -r '.rate_limits.five_hour.used_percentage // empty') | |
| set week_pct (echo $input | jq -r '.rate_limits.seven_day.used_percentage // empty') | |
| set limits "" | |
| if test -n "$five_pct" | |
| set limits "5h:"(printf "%.0f" $five_pct)"%" | |
| end | |
| if test -n "$week_pct" | |
| if test -n "$limits" | |
| set limits "$limits 7d:"(printf "%.0f" $week_pct)"%" | |
| else | |
| set limits "7d:"(printf "%.0f" $week_pct)"%" | |
| end | |
| end | |
| # Assemble output | |
| set parts | |
| if test -n "$desc" | |
| set parts $parts $desc | |
| end | |
| if test -n "$short_cwd" | |
| set parts $parts $short_cwd | |
| end | |
| if test -n "$branch" | |
| set parts $parts "[$branch]" | |
| end | |
| if test -n "$limits" | |
| set parts $parts $limits | |
| end | |
| printf "%s" (string join " | " $parts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment