aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/__claude-code-statusline
blob: e315e1f436e11aa90b7014ea37beec75b37d37a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env bash

# https://docs.anthropic.com/en/docs/claude-code/statusline

input="$(cat)"

cwd="$(echo "$input" | jq -r '.cwd')"
model="$(echo "$input" | jq -r '.model.display_name')"
# Sum consumed token counts and format it like "12.3k".
consumed_tokens="$(echo "$input" | jq -r '
    (.context_window.current_usage // {}) |
    (.input_tokens // 0) + (.cache_creation_input_tokens // 0) + (.cache_read_input_tokens // 0) |
    [. * 10 / 1000, 0] | max | floor / 10 | " \(.)k"
')"
used_percentage="$(echo "$input" | jq -r '.context_window.used_percentage // 0 | " @ \(.)%"')"
cost="$(echo "$input" | jq -r '.cost.total_cost_usd // 0 | . * 100 | floor / 100 | " ($\(.))"')"

echo "[$model]$consumed_tokens$used_percentage$cost ${cwd/#$HOME/\~}"