Claude Code之Statusline小工具 大用处

这是最近新出的功能状态栏配置, 要求版本至少是 1.0.72, 官方文档已经很详细,具体可以参考 claude-code/statusline

状态栏配置用途

为 Claude Code 创建自定义状态栏以显示上下文信息

通过自定义状态栏让 Claude Code 成为您专属的工具,该状态栏显示在 Claude Code 界面底部,类似于终端提示符(PS1)在 Oh-my-zsh 等 shell 中的工作方式。

示例

创建自定义状态栏

官方给了两种方式:

  • 运行 /statusline 让 Claude Code 帮助您设置自定义状态栏。默认情况下,它会尝试复制您终端的提示符,但您可以向 Claude Code 提供关于所需行为的额外说明,例如 /statusline show the model name in orange
  • 直接在 .claude/settings.json 中添加 statusLine 命令(推荐用这种)

另外我的 code-pilot 默认也集成了基础版本的,具体可以参考 settings.example

"statusLine": {
    "type": "command",
    "command": "~/.claude/scripts/statusline.sh",
    "padding": 0
  }

不过,本文主要将如何使用佬友写的 CCometixLine

CCometixLine 配置指南

有兴趣的可以查阅佬友的原文 Claude Code StatusLine | 小工具 大用处

由于我个人的习惯, 二进制放 bin,脚本放 scripts 目录下

20:26 ➜  .claude git:(master) tree -L 1
.
├── assets
├── bin
├── scripts
├── settings.json
└── CLAUDE.md

11 directories, 11 files

项目地址: CCometixLine

macOS 部署

涉及到非中文字体安装, 主要是 CCometixLine 图标依靠 Nerd Font

brew tap laishulu/homebrew
 brew install font-meslo-lg-nerd-font

佬友推荐了:

  • MesloLGS NF(Powerlevel10k 官方推荐)
  • FiraCode Nerd Font(支持编程连字)
  • JetBrainsMono Nerd Font(现代等宽字体)
  • Hack Nerd Font(清晰易读)

安装完成后设置 iTerm2 的字体,主要设置我勾选的那个就可以使图标生效

示例

配置也比较简单, 从 github 下载对应的二进制压缩包,解压放到对应的目录即可,检查一下权限,需要有执行权限

mkdir -p ~/.claude/bin  
wget https://github.com/Haleclipse/CCometixLine/releases/latest/download/ccline-macos-arm64.tar.gz
tar -xzf ccline-macos-arm64.tar.gz
cp ccline ~/.claude/bin/
chmod +x ~/.claude/bin/ccline

然后 settings.json 配置如下:

cat settings.json | jq .statusLine
{
  "type": "command",
  "command": "~/.claude/bin/ccline",
  "padding": 0
}

linux 部署

佬友提供的,可能受限于编译环境,可能提示 glibc 问题。现象就是配置了不生效,可以使用 .claude/bin/ccline -V 测试,如果能提示版本就没问题。

这里我也提供一个在 Debian13(12)都可以运行

https://c.ysicing.net/oss/tiga/linux/amd64/ccline-linux-amd64

其他

除了这些外,还可以使用 ccusage, 可以实时看到今天的总费用、当前活跃的 5 小时区块费用 & 剩余时间、实时消耗速率

{
  "statusLine": {
    "type": "command",
    "command": "bun x ccusage statusline"
  }
}

Sponsor

Like this article? $1 reward

Comments