Files
tech/.claude/tools/status_line.sh
T
arno 1d4041c8b8 配置: 添加 Claude Code 自定义状态栏
- 新增 status_line.sh 脚本,自定义状态栏显示格式
- 配置 CLAUDE_CODE_NO_FLICKER 禁止状态栏闪烁
- 状态栏显示:版本、模型、上下文使用百分比
2026-04-14 08:26:42 +08:00

29 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Read JSON data that Claude Code sends to stdin
input=$(cat)
# Extract fields using jq
MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
# The "// 0" provides a fallback if the field is null
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
V=$(echo "$input" | jq -r '.version')
BRANCH=""
if command -v jj >/dev/null 2>&1 && jj repo root >/dev/null 2>&1; then
BRANCH="🌿 $(jj log -r '@-' -T 'bookmarks' --no-graph 2>/dev/null)"
elif git rev-parse --git-dir >/dev/null 2>&1; then
BRANCH="🌿 $(git branch --show-current 2>/dev/null)"
fi
REMOTE=""
if command -v jj >/dev/null 2>&1 && jj repo root >/dev/null 2>&1; then
REMOTE="🌐 $(jj git remote list 2>/dev/null | head -1 | awk '{print $2}')"
elif git rev-parse --git-dir >/dev/null 2>&1; then
REMOTE="🌐 $(git remote get-url origin 2>/dev/null)"
fi
# echo "v$V | $MODEL | ${PCT}% context | 📁 ${DIR##*/} | $BRANCH $REMOTE"
echo "版本:v$V | 模型:$MODEL | 上下文:${PCT}%"