Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Everything in the [Claude Code status line documentation](https://code.claude.co
| `$cship.usage_limits` | API usage limits (5hr / 7-day, plus per-model and extra-usage when available) |
| `$cship.usage_limits.per_model` | 7-day per-model breakdown (opus / sonnet / cowork / oauth) |
| `$cship.usage_limits.extra_usage` | Extra-credits section with `{active}` indicator |
| `$cship.usage_limits.session` / `.weekly` | The 5h / 7d window alone, colored by its own utilization (aliases: `.five_hour` / `.seven_day`; supports a `{bar}`) |
| `$cship.account` | Authenticated Anthropic account (work/personal); map org names via `labels` |
| `$cship.peak_usage` | Peak-time indicator (US Pacific business hours) |
| `$cship.agent` | Sub-agent name |
Expand Down
25 changes: 25 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,30 @@ Displays 5-hour and 7-day API utilization percentages with time-to-reset.
| `$cship.usage_limits.cowork` | 7-day Cowork utilization only |
| `$cship.usage_limits.oauth_apps` | 7-day OAuth-apps utilization only |
| `$cship.usage_limits.extra_usage` | Extra-credits display (only when the account has extra usage enabled) |
| `$cship.usage_limits.session` (alias `.five_hour`) | Only the 5h window, colored by *its own* utilization |
| `$cship.usage_limits.weekly` (alias `.seven_day`) | Only the 7d window, colored by *its own* utilization |

The sub-tokens let you place sections independently in your `lines` layout — e.g., keep the 5h/7d pair on one row and push per-model onto a second row.

Unlike `$cship.usage_limits` (whose threshold color keys off the *higher* of the two windows), the `session` and `weekly` tokens each escalate independently on their own percentage. Combined with the `{bar}` placeholder and `bar_width`, this lets you render a separate progress bar per window — one line for the 5h session, one for the 7d week — each turning yellow/red on its own:

```toml
[cship]
lines = [
"$cship.usage_limits.session",
"$cship.usage_limits.weekly",
]

[cship.usage_limits]
five_hour_format = "5h {bar} {pct}%"
seven_day_format = "7d {bar} {pct}%"
bar_width = 20
warn_threshold = 50
warn_style = "yellow"
critical_threshold = 80
critical_style = "bold red"
```

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `disabled` | `bool` | `false` | Hide this module |
Expand All @@ -417,6 +438,9 @@ The sub-tokens let you place sections independently in your `lines` layout — e
| `extra_usage_format` | `string` | `"{active} extra: {pct}% (${used}/${limit})"` | Format for the extra-usage section |
| `show_per_model` | `bool` | `false` | When `true`, `$cship.usage_limits` appends the per-model breakdown (opus, sonnet, cowork, oauth) to the default `5h \| 7d` output. The extra-usage section always renders when enabled, regardless of this flag. Default is `false` so existing status bars retain their pre-1.5 shape. |
| `separator` | `string` | `" \| "` | String placed between sections |
| `bar_width` | `integer` | `10` | Width (chars) of the `{bar}` placeholder |
| `bar_filled_char` | `string` | `"█"` | Filled character for `{bar}` |
| `bar_empty_char` | `string` | `"░"` | Empty character for `{bar}` |
| `warn_threshold` | `float` | — | % at which style switches to `warn_style` |
| `warn_style` | `string` | `"yellow"` | Style at warn level |
| `critical_threshold` | `float` | — | % at which style switches to `critical_style` |
Expand All @@ -432,6 +456,7 @@ The sub-tokens let you place sections independently in your `lines` layout — e
| `{reset}` | Time-until-reset string (e.g. `4h12m`) |
| `{reset_at}` | Absolute local reset time — clock-only if today (e.g. `7:42 PM`), weekday-prefixed otherwise (e.g. `Mon 9:00 AM`); `?` if unknown, `now` if already past |
| `{pace}` | Signed headroom vs linear consumption — `+20%` (under pace), `-15%` (over pace), or `?` when unknown |
| `{bar}` | Proportional Unicode bar for this window (e.g. `████░░░░░░`), sized by `bar_width`. **`five_hour_format` / `seven_day_format` only** (and the `session` / `weekly` tokens); not substituted in the per-model or extra-usage formats. |

**Placeholders specific to `extra_usage_format`** (the standard `{remaining}` percentage placeholder does **not** apply here — use `{remaining_credits}` instead):

Expand Down
27 changes: 27 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,33 @@ extra_usage_format = "{active} ${used}/${limit}"

---

## How do I show the session and weekly limits on separate lines, each with its own bar and color?

`$cship.usage_limits` renders both windows together and colors the whole segment off the *higher* of the two (so a hot 5h window turns the 7d text red as well). The per-window tokens render each window on its own and color it off **its own** utilization:

- `$cship.usage_limits.session` — the 5-hour window (alias `.five_hour`)
- `$cship.usage_limits.weekly` — the 7-day window (alias `.seven_day`)

Combine them with the `{bar}` placeholder (available in `five_hour_format` / `seven_day_format`, sized by `bar_width`) to get an independent progress bar per window:

```toml
[cship]
lines = ["$cship.usage_limits.session", "$cship.usage_limits.weekly"]

[cship.usage_limits]
five_hour_format = "5h {bar} {pct}%"
seven_day_format = "7d {bar} {pct}%"
bar_width = 20
warn_threshold = 50
warn_style = "yellow"
critical_threshold = 80
critical_style = "bold red"
```

Now the 5h bar can be green while the 7d bar is red (or vice versa), each escalating on its own percentage.

---

## I'm on a Claude Enterprise plan and `cship.usage_limits` shows nothing — why?

Claude Enterprise reports usage through `extra_usage` (monthly credit pool)
Expand Down
23 changes: 23 additions & 0 deletions docs/public/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,29 @@
"string",
"null"
]
},
"bar_width": {
"description": "Width (in characters) of the `{bar}` placeholder available in\n`five_hour_format` / `seven_day_format` and the per-period tokens\n(`$cship.usage_limits.session`/`.weekly`, a.k.a. `.five_hour`/`.seven_day`).\nDefault: 10.",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"bar_filled_char": {
"description": "Filled character for the `{bar}` placeholder. Default: \"█\".",
"type": [
"string",
"null"
]
},
"bar_empty_char": {
"description": "Empty character for the `{bar}` placeholder. Default: \"░\".",
"type": [
"string",
"null"
]
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ pub struct UsageLimitsConfig {
/// Placeholders: {pct}, {reset}, {remaining}, {pace}
/// Default: "oauth {pct}%"
pub oauth_apps_format: Option<String>,
/// Width (in characters) of the `{bar}` placeholder available in
/// `five_hour_format` / `seven_day_format` and the per-period tokens
/// (`$cship.usage_limits.session`/`.weekly`, a.k.a. `.five_hour`/`.seven_day`).
/// Default: 10.
pub bar_width: Option<u32>,
/// Filled character for the `{bar}` placeholder. Default: "█".
pub bar_filled_char: Option<String>,
/// Empty character for the `{bar}` placeholder. Default: "░".
pub bar_empty_char: Option<String>,
}

/// Configuration for `[cship.peak_usage]` — peak-time indicator.
Expand Down
13 changes: 10 additions & 3 deletions src/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,28 @@ fn error_hint_for(
.as_deref()
.map(std::path::Path::new)
.and_then(|p| crate::cache::read_usage_limits(p, true, None));
let is_per_model_subtoken = matches!(
// Sub-tokens that require a standard 5h/7d signal and so are
// inherently absent on Enterprise (per-window and per-model).
let is_plan_specific_subtoken = matches!(
top,
"usage_limits.per_model"
| "usage_limits.opus"
| "usage_limits.sonnet"
| "usage_limits.cowork"
| "usage_limits.oauth_apps"
| "usage_limits.five_hour"
| "usage_limits.seven_day"
| "usage_limits.session"
| "usage_limits.weekly"
);
match cached {
Some(d)
if crate::modules::usage_limits::lacks_standard_signal(&d)
&& is_per_model_subtoken =>
&& is_plan_specific_subtoken =>
{
(
"per-model breakdowns are unavailable on this plan".into(),
"the 5h/7d and per-model breakdowns are unavailable on this plan"
.into(),
"Claude Enterprise reports usage via monthly credits (`extra_usage`) only. Use `$cship.usage_limits` or `$cship.usage_limits.extra_usage` instead.".into(),
)
}
Expand Down
10 changes: 10 additions & 0 deletions src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub const ALL_NATIVE_MODULES: &[&str] = &[
"cship.usage_limits.cowork",
"cship.usage_limits.oauth_apps",
"cship.usage_limits.extra_usage",
"cship.usage_limits.five_hour",
"cship.usage_limits.seven_day",
"cship.usage_limits.session",
"cship.usage_limits.weekly",
"cship.peak_usage",
"cship.account",
];
Expand Down Expand Up @@ -137,6 +141,12 @@ pub fn render_module(
"cship.usage_limits.cowork" => usage_limits::render_cowork(ctx, cfg),
"cship.usage_limits.oauth_apps" => usage_limits::render_oauth_apps(ctx, cfg),
"cship.usage_limits.extra_usage" => usage_limits::render_extra_usage(ctx, cfg),
"cship.usage_limits.five_hour" | "cship.usage_limits.session" => {
usage_limits::render_five_hour(ctx, cfg)
}
"cship.usage_limits.seven_day" | "cship.usage_limits.weekly" => {
usage_limits::render_seven_day(ctx, cfg)
}
"cship.peak_usage" => peak_usage::render(ctx, cfg),
"cship.account" => account::render(ctx, cfg),
other => {
Expand Down
Loading