diff --git a/ai-setup.sh b/ai-setup.sh index be87985..c949407 100755 --- a/ai-setup.sh +++ b/ai-setup.sh @@ -638,7 +638,36 @@ else info "Папка со skills не найдена, пропускаю" fi -# ── 6.7. Регистрация официального маркетплейса плагинов Claude ── +# ── 6.7. Статусная строка Claude Code ─────────────────────── +info "Настраиваю статусную строку Claude Code..." +STATUSLINE_SRC="$SCRIPT_DIR/home-configs/claude/statusline-command.sh" +STATUSLINE_DST="$HOME/.claude/statusline-command.sh" +if [ -f "$STATUSLINE_SRC" ]; then + cp "$STATUSLINE_SRC" "$STATUSLINE_DST" + chmod +x "$STATUSLINE_DST" + # Вписываем statusLine в settings.json через python3 + SETTINGS="$HOME/.claude/settings.json" + python3 - "$SETTINGS" "$STATUSLINE_DST" <<'PYEOF' +import sys, json, os +settings_path, script_path = sys.argv[1], sys.argv[2] +data = {} +if os.path.exists(settings_path): + with open(settings_path) as f: + try: + data = json.load(f) + except json.JSONDecodeError: + pass +data["statusLine"] = {"type": "command", "command": f"bash {script_path}"} +with open(settings_path, "w") as f: + json.dump(data, f, indent=2, ensure_ascii=False) + f.write("\n") +PYEOF + success "Статусная строка настроена" +else + warn "Файл $STATUSLINE_SRC не найден, пропускаю" +fi + +# ── 6.8. Регистрация официального маркетплейса плагинов Claude ── info "Настраиваю маркетплейс плагинов Claude Code..." if ! command -v claude &>/dev/null; then warn "claude не найден, пропускаю настройку маркетплейса" @@ -667,7 +696,7 @@ else fi fi -# ── 6.8. Установка Claude Notifier ────────────────────────── +# ── 6.9. Установка Claude Notifier ────────────────────────── info "Устанавливаю Claude Notifier..." if [ -f "$HOME/.claude/hooks/claude-notifier-on-stop.js" ]; then success "Claude Notifier уже установлен" diff --git a/home-configs/claude/statusline-command.sh b/home-configs/claude/statusline-command.sh new file mode 100644 index 0000000..f49e031 --- /dev/null +++ b/home-configs/claude/statusline-command.sh @@ -0,0 +1,19 @@ +#!/bin/bash +input=$(cat) +cwd=$(echo "$input" | jq -r '.cwd') +model=$(echo "$input" | jq -r '.model.display_name // empty') +five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty') +week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') + +branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null) + +printf "\033[01;32m%s@%s\033[00m:\033[01;34m%s\033[00m" "$(whoami)" "$(hostname -s)" "$cwd" + +[ -n "$branch" ] && printf " \033[01;33m[%s]\033[00m" "$branch" +[ -n "$model" ] && printf " \033[00;36m%s\033[00m" "$model" + +if [ -n "$five_pct" ]; then + printf " \033[00;35m5h:$(printf '%.0f' "$five_pct")%%\033[00m" +elif [ -n "$week_pct" ]; then + printf " \033[00;35m7d:$(printf '%.0f' "$week_pct")%%\033[00m" +fi