Skip to content

Commit 71a3574

Browse files
authored
Merge pull request #232 from shelltime/docs/update-cc-statusline-docs
docs(cc-statusline): update docs for clickable links and new fields
2 parents 0818da4 + adb54df commit 71a3574

2 files changed

Lines changed: 58 additions & 21 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@ Add to your Claude Code settings (`~/.claude/settings.json`):
8888
The status line will display:
8989

9090
```
91-
🤖 Opus | 💰 $0.12 | 📊 $3.45 | 📈 45%
91+
🌿 main* | 🤖 Opus | 💰 $0.12 | 📊 $3.45 | 🚦 5h:23% 7d:12% | ⏱️ 5m30s | 📈 45%
9292
```
9393

9494
| Section | Description |
9595
|---------|-------------|
96+
| 🌿 Git Branch | Current branch name (`*` if dirty) |
9697
| 🤖 Model | Current model name |
97-
| 💰 Session | Current session cost |
98-
| 📊 Today | Today's total cost (requires daemon + OTEL) |
98+
| 💰 Session | Current session cost (clickable link to session detail) |
99+
| 📊 Daily | Today's total cost (clickable link to coding agent page) |
100+
| 🚦 Quota | Anthropic API quota utilization (macOS only, clickable link to usage settings) |
101+
| ⏱️ Time | AI agent session duration (clickable link to user profile) |
99102
| 📈 Context | Context window usage % |
100103

101104
For full details, see [Claude Code Statusline Guide](docs/CC_STATUSLINE.md).

docs/CC_STATUSLINE.md

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `shelltime cc statusline` command provides a custom status line for Claude C
1212
- Today's total cost (from ShellTime API)
1313
- AI agent time (session duration)
1414
- Context window usage percentage
15-
- Anthropic API quota utilization (5-hour and 7-day windows)
15+
- Anthropic API quota utilization (5-hour and 7-day windows, macOS only)
1616

1717
## Quick Start
1818

@@ -41,15 +41,28 @@ The status line will appear at the bottom of Claude Code:
4141

4242
## Output Format
4343

44-
| Section | Emoji | Description | Color |
45-
|---------|-------|-------------|-------|
46-
| Git | 🌿 | Current branch name (`*` if dirty) | Green |
47-
| Model | 🤖 | Current model display name | Default |
48-
| Session | 💰 | Current session cost in USD | Cyan |
49-
| Today | 📊 | Today's total cost from API | Yellow |
50-
| Quota | 🚦 | Anthropic API quota utilization | Green/Yellow/Red |
51-
| Time | ⏱️ | AI agent session duration | Magenta |
52-
| Context | 📈 | Context window usage % | Green/Yellow/Red |
44+
| Section | Emoji | Description | Color | Clickable Link |
45+
|---------|-------|-------------|-------|----------------|
46+
| Git | 🌿 | Current branch name (`*` if dirty) | Green (Gray if unavailable) ||
47+
| Model | 🤖 | Current model display name | Default ||
48+
| Session | 💰 | Current session cost in USD | Cyan | Session detail page |
49+
| Daily | 📊 | Today's total cost from API | Yellow when > 0, Gray when 0 | Coding agent page |
50+
| Quota | 🚦 | Anthropic API quota utilization | Green/Yellow/Red (Gray if unavailable) | Claude usage settings (always linked) |
51+
| Time | ⏱️ | AI agent session duration | Magenta when > 0, Gray when 0 | User profile page |
52+
| Context | 📈 | Context window usage % | Green/Yellow/Red ||
53+
54+
### Clickable Links
55+
56+
All cost and usage sections support terminal hyperlinks using the [OSC 8 protocol](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). Click on the section text in a supported terminal to open the corresponding page:
57+
58+
| Section | Link Target |
59+
|---------|-------------|
60+
| 💰 Session Cost | `{webEndpoint}/users/{login}/coding-agent/session/{sessionID}` |
61+
| 📊 Daily Cost | `{webEndpoint}/users/{login}/coding-agent/claude-code` |
62+
| 🚦 Quota | `https://claude.ai/settings/usage` (always linked, even when showing `-`) |
63+
| ⏱️ Time | `{webEndpoint}/users/{login}` (user profile) |
64+
65+
Session and Daily links require a configured ShellTime account (`userLogin` and `webEndpoint` from daemon). The Quota link is always active regardless of data availability.
5366

5467
### Git Status Indicator
5568

@@ -69,6 +82,10 @@ The quota section displays your Anthropic API rate limit utilization across two
6982

7083
The percentage is clickable and links to your [Claude usage settings](https://claude.ai/settings/usage) page.
7184

85+
### Platform Note
86+
87+
On **Linux**, the quota section (`🚦`) is omitted entirely from the output — the statusline skips from Daily Cost to Time. On **macOS**, it is always shown (either with data or as `🚦 -`).
88+
7289
### Quota Color Coding
7390

7491
Color is based on the **maximum** utilization across both windows:
@@ -96,16 +113,22 @@ Color is based on the **maximum** utilization across both windows:
96113
- Model name from `model.display_name`
97114
- Session cost from `cost.total_cost_usd`
98115
- Context usage from `context_window`
99-
- Working directory from `working_directory`
100-
3. **Git info** is fetched from the daemon (which caches it for performance)
101-
4. **Daily cost** is fetched from ShellTime GraphQL API (cached for 5 minutes)
102-
5. **Quota utilization** is fetched from Anthropic OAuth API by the daemon (cached for 10 minutes)
103-
6. **Output** is a single formatted line with ANSI colors
116+
- Working directory from `cwd`
117+
- Session ID from `session_id` (used for session cost link)
118+
- Workspace info from `workspace` (used for session-project mapping)
119+
3. **Session-project mapping** is sent to the daemon as a fire-and-forget message (~1ms), associating the session ID with its project directory
120+
4. **Git info** is fetched from the daemon (which caches it for performance)
121+
5. **Daily cost** is fetched from ShellTime GraphQL API (cached for 5 minutes)
122+
6. **Quota utilization** is fetched from Anthropic OAuth API by the daemon (cached for 10 minutes)
123+
7. **Clickable links** are added to Session, Daily, Quota, and Time sections using OSC 8 terminal hyperlinks
124+
8. **Output** is a single formatted line with ANSI colors
104125

105126
### JSON Input (from Claude Code)
106127

107128
```json
108129
{
130+
"hook_event_name": "StatusLine",
131+
"session_id": "abc123-def456",
109132
"model": {
110133
"id": "claude-opus-4-1",
111134
"display_name": "Opus"
@@ -125,7 +148,12 @@ Color is based on the **maximum** utilization across both windows:
125148
"cache_read_input_tokens": 2000
126149
}
127150
},
128-
"working_directory": "/home/user/projects/my-app"
151+
"cwd": "/home/user/projects/my-app",
152+
"version": "1.0.0",
153+
"workspace": {
154+
"current_dir": "/home/user/projects/my-app",
155+
"project_dir": "/home/user/projects/my-app"
156+
}
129157
}
130158
```
131159

@@ -171,7 +199,7 @@ If no token is configured, the daily cost will show as `-`.
171199

172200
Requires **macOS** and the ShellTime daemon running. The daemon reads Claude Code's OAuth token from the macOS Keychain (service name: `Claude Code-credentials`) and queries the Anthropic usage API.
173201

174-
- **macOS only** - Keychain access is required to retrieve the OAuth token
202+
- **macOS only** - Keychain access is required to retrieve the OAuth token; on Linux the quota section is omitted entirely
175203
- **Daemon required** - quota data is fetched and cached by the daemon's background timer
176204
- **No manual setup** - if you're logged into Claude Code on macOS, it works automatically
177205

@@ -182,6 +210,8 @@ If quota data is unavailable, the section will show as `🚦 -`.
182210
## Performance
183211

184212
- **Hard timeout:** 100ms for entire operation
213+
- **Daemon request timeout:** 50ms for the daemon socket request (fast path)
214+
- **Session mapping:** ~1ms fire-and-forget to daemon
185215
- **API caching:** 5-minute TTL for daily cost, 10-minute TTL for quota utilization
186216
- **Git info caching:** Daemon fetches git info in background timer loop, not on-demand
187217
- **Quota caching:** Daemon fetches quota data asynchronously with rate-limit protection
@@ -212,7 +242,7 @@ If quota data is unavailable, the section will show as `🚦 -`.
212242

213243
### Quota shows `-`
214244

215-
1. Ensure you're on **macOS** - quota display is only available on macOS
245+
1. Ensure you're on **macOS** - quota display is only available on macOS (omitted entirely on Linux)
216246
2. Verify you're logged into Claude Code (the OAuth token is stored in macOS Keychain)
217247
3. Ensure the daemon is running: `shelltime daemon status`
218248
4. Quota data is cached for 10 minutes - it may take a moment after daemon start
@@ -221,6 +251,10 @@ If quota data is unavailable, the section will show as `🚦 -`.
221251

222252
Your terminal may not support ANSI colors. Check terminal settings or try a different terminal emulator.
223253

254+
### Links not clickable
255+
256+
Your terminal must support the [OSC 8 hyperlink protocol](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). Most modern terminals (iTerm2, WezTerm, Windows Terminal, GNOME Terminal 3.26+) support it. Older terminals or multiplexers (tmux, screen) may not.
257+
224258
---
225259

226260
## Related

0 commit comments

Comments
 (0)