Claude Code Status Line
Install a security-hardened status line for Claude Code CLI that displays:
CODEBLOCK0
Prerequisites
- - Python 3 (standard library only, no pip dependencies)
- INLINECODE0 (optional, for branch display)
Script
INLINECODE1 -- Python 3, standard library only.
CODEBLOCK1
How It Works
- 1. install -- Copies
statusline.py to ~/.claude/scripts/, creates config at ~/.claude/statusline.config (perms 600), updates ~/.claude/settings.local.json with python3 ~/.claude/scripts/statusline.py command.
- 2. status -- JSON output: script installed, config state, settings configured, git availability.
- 3. configure -- Update thresholds (
--threshold-yellow/orange/red), colors (--color-green/yellow/orange/red), display mode (--token-display separate|combined). Validates threshold ordering.
- 4. uninstall -- Removes script, reverts settings.
--remove-config also deletes config file.
Configuration
Config file: ~/.claude/statusline.config
| Option | Default | Values |
|---|
| INLINECODE12 | INLINECODE13 | INLINECODE14 (In/Out/Cache), combined (total) |
| INLINECODE16 |
40 | 0-100 |
|
THRESHOLD_ORANGE |
50 | 0-100 |
|
THRESHOLD_RED |
70 | 0-100 |
|
COLOR_* | standard ANSI | Color name or ANSI code |
Available colors: green, yellow, orange, red, blue, cyan, magenta, purple, white, pink, bright-green, bright-yellow, bright-red, bright-blue, bright-cyan, bright-magenta.
After Install
Restart Claude Code (exit then claude) to activate.
Claude Code 状态栏
为 Claude Code CLI 安装一个安全加固的状态栏,显示内容如下:
user@host:dir (branch) | Model | In:8.5K Out:1.2K Cache:7K [23%]
前置条件
- - Python 3(仅使用标准库,无需 pip 依赖)
- git(可选,用于显示分支信息)
脚本
scripts/statusline_installer.py -- Python 3,仅使用标准库。
bash
使用默认设置安装
python3 scripts/statusline_installer.py install
使用自定义阈值安装
python3 scripts/statusline_installer.py install --threshold-yellow 30 --threshold-orange 50 --threshold-red 70
使用合并令牌显示模式安装
python3 scripts/statusline_installer.py install --token-display combined
检查安装状态
python3 scripts/statusline_installer.py status
更新配置
python3 scripts/statusline_installer.py configure --threshold-red 80 --color-green cyan
卸载
python3 scripts/statusline_installer.py uninstall [--remove-config]
工作原理
- 1. install -- 将 statusline.py 复制到 ~/.claude/scripts/,在 ~/.claude/statusline.config 创建配置文件(权限 600),使用 python3 ~/.claude/scripts/statusline.py 命令更新 ~/.claude/settings.local.json。
- 2. status -- JSON 格式输出:脚本安装状态、配置状态、设置配置情况、git 可用性。
- 3. configure -- 更新阈值(--threshold-yellow/orange/red)、颜色(--color-green/yellow/orange/red)、显示模式(--token-display separate|combined)。验证阈值顺序。
- 4. uninstall -- 移除脚本,恢复设置。--remove-config 同时删除配置文件。
配置
配置文件:~/.claude/statusline.config
| 选项 | 默认值 | 可选值 |
|---|
| TOKENDISPLAY | separate | separate(输入/输出/缓存分开显示),combined(显示总计) |
| THRESHOLDYELLOW |
40 | 0-100 |
| THRESHOLD_ORANGE | 50 | 0-100 |
| THRESHOLD_RED | 70 | 0-100 |
| COLOR_* | 标准 ANSI 颜色 | 颜色名称或 ANSI 代码 |
可用颜色:green, yellow, orange, red, blue, cyan, magenta, purple, white, pink, bright-green, bright-yellow, bright-red, bright-blue, bright-cyan, bright-magenta。
安装后
重启 Claude Code(输入 exit 然后 claude)以激活。