You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,7 @@ Key sections in `claude-code-status-line.py` (~2,200 lines):
73
73
-**Usage data source**: CC 2.1.80+ sends `rate_limits` in stdin JSON (preferred). Falls back to deprecated OAuth API (`fetch_usage_data()`) for older CC versions. OAuth path (`get_oauth_token()`, `USAGE_CACHE_PATH`, `SL_USAGE_CACHE_DURATION`) will be removed in a future version.
74
74
-**Credential sources**: macOS Keychain (`security` command) → `~/.claude/.credentials.json` fallback (deprecated, only used by OAuth fallback).
75
75
-**Cache writes**: atomic via `tempfile.mkstemp()` + `os.replace()` with temp file cleanup on failure.
76
+
-**Plugin system**: auto-discovers `.py` files in `.claude/statusline/` (project-level, cwd-relative) and `~/.claude/statusline/` (global). Each plugin defines `register(api)` where `api` provides `add_segment(name, renderer, defaults)`, `fg(color)`, `bg(color)`, `text_color(key)`, `RESET`, `BOLD`. Registered segments become valid in `SL_SEGMENTS`. Plugin errors are silently ignored. The `ctx` dict passed to renderers includes `data` (raw JSON from Claude Code stdin) so plugins can access `session_id`, `cwd`, and other fields.
76
77
-**No type hints** per project convention — uses f-strings throughout.
77
78
-**Effort level limitations**: The statusline JSON from Claude Code does NOT include effort level. The `model:effort` option reads from settings files as a workaround. Known gaps:
78
79
-`max` is session-only (never written to disk) — undetectable
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ A statusline script for [Claude Code](https://docs.anthropic.com/en/docs/claude-
27
27
-**Usage** tracking both 5-hour and 7-day window showing what needs to be known (how much, to when and how much you're burning through them)
28
28
-**Dark and light theme** support (Nord-inspired palette) with option to customize.
29
29
-**Truecolor (24-bit)** with automatic 256-color fallback
30
+
-**Plugin system** for custom segments
30
31
-**Customization of what is shown and how**
31
32
32
33
## Installation
@@ -335,6 +336,53 @@ Countdown omits the renewal gap when it rounds to ≤ 1 hour. Color-coded: orang
335
336
336
337
The script checks the `COLORTERM` environment variable for `truecolor` or `24bit`. If present, it uses 24-bit RGB colors. Otherwise, it falls back to 256-color mode using the fallback values defined in the theme.
337
338
339
+
## Plugins
340
+
341
+
Extend the statusline with custom segments by dropping `.py` files into plugin directories:
342
+
343
+
1.**Project-level:**`.claude/statusline/` (relative to cwd)
344
+
2.**Global:**`~/.claude/statusline/`
345
+
346
+
Each plugin defines a `register(api)` function that registers one or more segments:
|`api.add_segment(name, renderer, defaults=None)`| Register a segment. `renderer(ctx, opts) -> str`|
374
+
|`api.fg(color)`| Foreground ANSI code. `"#RRGGBB"` (truecolor with 256 fallback) or `int` (256-color) |
375
+
|`api.bg(color)`| Background ANSI code. Same formats |
376
+
|`api.text_color(key)`| Themed text color by key (e.g. `"percent"`, `"cwd"`, `"git"`) |
377
+
|`api.RESET`| ANSI reset escape |
378
+
|`api.BOLD`| ANSI bold escape |
379
+
380
+
The `ctx` dict passed to renderers includes all standard fields (model, cwd, pct, tokens, usage data) plus `data` — the raw JSON input from Claude Code, giving access to `session_id`, `cwd`, and other fields.
381
+
382
+
The `opts` dict contains per-segment options from `SL_SEGMENTS` colon syntax (e.g. `session:short=1` → `opts = {"short": "1"}`). Use `defaults` in `add_segment()` to set fallback values.
383
+
384
+
Plugin errors are silently ignored — a broken plugin never breaks the statusline.
385
+
338
386
## Contributing
339
387
340
388
This is a personal tool that I built for my own workflow. You're welcome to fork it and adapt it to your needs.
0 commit comments