From 1d4041c8b8ade28c18e731cd5b69ac645e572902 Mon Sep 17 00:00:00 2001 From: arno Date: Tue, 14 Apr 2026 08:26:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE:=20=E6=B7=BB=E5=8A=A0=20Clau?= =?UTF-8?q?de=20Code=20=E8=87=AA=E5=AE=9A=E4=B9=89=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 status_line.sh 脚本,自定义状态栏显示格式 - 配置 CLAUDE_CODE_NO_FLICKER 禁止状态栏闪烁 - 状态栏显示:版本、模型、上下文使用百分比 --- .claude/settings.json | 7 ++++++- .claude/tools/status_line.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 .claude/tools/status_line.sh diff --git a/.claude/settings.json b/.claude/settings.json index 8fd958c..5aca21f 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -1,7 +1,8 @@ { "env": { "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "200000", - "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "75" + "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "75", + "CLAUDE_CODE_NO_FLICKER": "1" }, "hooks": { "UserPromptSubmit": [ @@ -14,5 +15,9 @@ ] } ] + }, + "statusLine": { + "type": "command", + "command": "/data/git/gitea/szis/isos/tech/.claude/tools/status_line.sh" } } diff --git a/.claude/tools/status_line.sh b/.claude/tools/status_line.sh new file mode 100755 index 0000000..f893a24 --- /dev/null +++ b/.claude/tools/status_line.sh @@ -0,0 +1,29 @@ +#!/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}%" \ No newline at end of file