statusline-install

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Statusline Specification

状态栏规范

Create a statusline with this exact format:
Model │ ↑Tokens ↓Tokens $Cost │ Duration +Lines -Lines │ Context%
Example output:
Opus │ ↑15k ↓4k $1.23 │ 5m (2m) +156 -23 │ 42%
创建一个完全符合以下格式的状态栏:
Model │ ↑Tokens ↓Tokens $Cost │ Duration +Lines -Lines │ Context%
示例输出:
Opus │ ↑15k ↓4k $1.23 │ 5m (2m) +156 -23 │ 42%

Data Sources

数据源

FieldJSON Path
Model
.model.display_name
Total duration
.cost.total_duration_ms
API duration
.cost.total_api_duration_ms
Input tokens
.context_window.total_input_tokens
Output tokens
.context_window.total_output_tokens
Cost
.cost.total_cost_usd
Lines added
.cost.total_lines_added
Lines removed
.cost.total_lines_removed
Context %
.context_window.used_percentage
字段JSON 路径
模型
.model.display_name
总时长
.cost.total_duration_ms
API 时长
.cost.total_api_duration_ms
输入令牌数
.context_window.total_input_tokens
输出令牌数
.context_window.total_output_tokens
成本
.cost.total_cost_usd
新增行数
.cost.total_lines_added
删除行数
.cost.total_lines_removed
上下文占用率
.context_window.used_percentage

Formatting Rules

格式化规则

Duration: Show as
Xs
,
Xm
, or
Xh Ym
— total time followed by API time in parentheses (always shown)
  • 5m (2m)
    = 5 min total, 2 min waiting for API
  • 1h 15m (45m)
    = 1 hour 15 min total, 45 min waiting for API
  • Empty state:
    0s (0s)
Tokens:
  • Raw number if < 1,000 →
    850
  • Lowercase
    k
    for thousands →
    15k
  • Lowercase
    m
    with 1 decimal for millions →
    1.2m
Cost:
  • 4 decimal places if < $0.01 →
    $0.0012
  • 2 decimal places if ≥ $0.01 →
    $0.12
Lines changed: Green for
+added
, Red for
-removed
Model name: Reset/default terminal color (wrap with
${RESET}
)
Separators: Dim box-drawing character
(U+2502)
General styling: Duration, tokens, and cost should be dim
时长:显示为
Xs
Xm
Xh Ym
—— 总时长后跟随括号内的API耗时(始终显示)
  • 5m (2m)
    = 总时长5分钟,API等待耗时2分钟
  • 1h 15m (45m)
    = 总时长1小时15分钟,API等待耗时45分钟
  • 空状态:
    0s (0s)
令牌数
  • 若小于1000则显示原始数字 →
    850
  • 千位用小写
    k
    表示 →
    15k
  • 百万位用小写
    m
    加1位小数表示 →
    1.2m
成本
  • 若小于0.01美元则保留4位小数 →
    $0.0012
  • 若大于等于0.01美元则保留2位小数 →
    $0.12
行数变更
+新增行数
为绿色,
-删除行数
为红色
模型名称:使用终端默认颜色(用
${RESET}
包裹)
分隔符:使用暗淡的方框绘制字符
(U+2502)
整体样式:时长、令牌数和成本需显示为暗淡样式

Context % Color Thresholds

上下文占用率颜色阈值

Auto-compact triggers at ~78%, so thresholds are calibrated accordingly:
RangeColorMeaning
0-49%GreenPlenty of room
50-64%YellowGetting used
65-74%OrangeApproaching auto-compact
75%+RedNear auto-compact trigger
自动压缩触发阈值约为78%,因此颜色阈值按此校准:
范围颜色含义
0-49%绿色剩余空间充足
50-64%黄色已使用部分空间
65-74%橙色接近自动压缩阈值
75%+红色即将触发自动压缩

ANSI Color Definitions (Bash)

ANSI颜色定义(Bash)

Define colors using
$'...'
syntax so escape sequences are interpreted. Use 24-bit true color format
\033[38;2;R;G;Bm
for precise colors:
bash
DIM=$'\033[38;2;153;153;153m'      # #999999
GREEN=$'\033[38;2;55;166;96m'      # #37A660
YELLOW=$'\033[33m'
ORANGE=$'\033[38;5;208m'
RED=$'\033[38;2;187;106;122m'      # #BB6A7A
RESET=$'\033[0m'
Always wrap colored output with
${COLOR}text${RESET}
.
使用
$'...'
语法定义颜色,以便转义序列被正确解析。使用24位真彩色格式
\033[38;2;R;G;Bm
实现精确颜色:
bash
DIM=$'\033[38;2;153;153;153m'      # #999999
GREEN=$'\033[38;2;55;166;96m'      # #37A660
YELLOW=$'\033[33m'
ORANGE=$'\033[38;5;208m'
RED=$'\033[38;2;187;106;122m'      # #BB6A7A
RESET=$'\033[0m'
始终用
${COLOR}文本${RESET}
包裹带颜色的输出内容。

Null Handling

空值处理

Default to
0
for numeric fields when null/missing:
  • Tokens:
    0
  • Cost:
    $0.0000
  • Duration:
    0s (0s)
  • Lines:
    +0
    /
    -0
  • Context:
    0%
Only show
--
for non-numeric fields like model name if truly unavailable.
当数值字段为null或缺失时,默认显示
0
  • 令牌数:
    0
  • 成本:
    $0.0000
  • 时长:
    0s (0s)
  • 行数:
    +0
    /
    -0
  • 上下文占用率:
    0%
只有当非数值字段(如模型名称)确实不可用时,才显示
--

Platform Notes

平台说明

  • macOS/Linux: Use bash with the ANSI definitions above
  • Windows: Use PowerShell 7+ (
    pwsh
    ). Use backtick syntax instead:
powershell
$Dim = "`e[38;2;153;153;153m"      # #999999
$Green = "`e[38;2;55;166;96m"      # #37A660
$Yellow = "`e[33m"
$Orange = "`e[38;5;208m"
$Red = "`e[38;2;187;106;122m"      # #BB6A7A
$Reset = "`e[0m"
Install to
~/.claude/
and update
~/.claude/settings.json
with the statusLine configuration.
  • macOS/Linux:使用Bash并采用上述ANSI颜色定义
  • Windows:使用PowerShell 7+(
    pwsh
    )。需使用反引号语法替代:
powershell
$Dim = "`e[38;2;153;153;153m"      # #999999
$Green = "`e[38;2;55;166;96m"      # #37A660
$Yellow = "`e[33m"
$Orange = "`e[38;5;208m"
$Red = "`e[38;2;187;106;122m"      # #BB6A7A
$Reset = "`e[0m"
将文件安装到
~/.claude/
目录,并更新
~/.claude/settings.json
中的statusLine配置。