Repository navigation
feat: ccswitch statusline puts the account in Claude Code's status line - #9
Merged
Merged
Conversation
One line shaped for the statusLine setting — profile, model, and both
rate-limit windows, amber at 70% and red with the reset time at 90%.
Sharing it everywhere is one command:
ccswitch defaults set statusLine '{"type":"command","command":"ccswitch statusline"}'
The status line runs its command constantly, so this path is a pure read:
usage comes from ~/.ccswitch/usage-cache.json, refreshed by a detached
helper at most every two minutes (the update-check pattern), profile
resolution matches directory names without reading any profile's
.claude.json, and even start-up housekeeping is skipped. Sessions
launched without ccswitch read the default ~/.claude and label
themselves claude.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
ccswitch statuslineprints one line shaped for Claude Code'sstatusLinesetting:CLAUDE_CONFIG_DIR(which ccswitch set at launch); foreign config dirs show their base name; a session launched without ccswitch reads the default~/.claudeand labels itselfclaude.ccswitch defaults set statusLine '{"type":"command","command":"ccswitch statusline"}'Never blocks the status line
The command fires many times a minute, so it is a pure read: usage comes from a new
~/.ccswitch/usage-cache.json, and a stale entry kicks a detachedstatusline-refreshhelper (same pattern as the update check) whose result shows up a tick later. A kick stamp bounds refresher spawning to one per 30s window; failed fetches are recorded so they don't refetch every render; writes are write-then-rename so concurrent readers never see a torn file. Profile resolution deliberately avoidsList()— reading every profile's.claude.json(which can be MBs) per tick — andstatuslineskips start-up binary cleanup too.Verified live: first call prints
BartAccount, kicks the refresher; seconds laterBartAccount · 5h 21% · wk 10%from real endpoint data.🤖 Generated with Claude Code