diff --git a/home-configs/claude/statusline-command.sh b/home-configs/claude/statusline-command.sh index 890644f..385f791 100755 --- a/home-configs/claude/statusline-command.sh +++ b/home-configs/claude/statusline-command.sh @@ -9,15 +9,36 @@ week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empt week_reset=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty') ctx_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') + +# Цвет effort: мягкая гармоничная палитра +_effort_color() { + case "$1" in + low) printf '\033[38;5;220m[low]\033[00m' ;; # золотой + medium) printf '\033[38;5;43m[medium]\033[00m' ;; # бирюзовый + high) printf '\033[38;5;39m[high]\033[00m' ;; # небесно-голубой + xhigh) printf '\033[38;5;171m[xhigh]\033[00m' ;; # лавандовый + max) printf '\033[38;5;210m[\033[38;5;220mm\033[38;5;114ma\033[38;5;43mx\033[38;5;171m]\033[00m' ;; # радуга + *) printf '\033[38;5;250m[%s]\033[00m' "$1" ;; + esac +} + branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null) short_cwd="${cwd/#$HOME/\~}" -printf "\033[00;37m%s\033[00m" "$short_cwd" +printf "\033[38;5;250m%s\033[00m" "$short_cwd" -[ -n "$branch" ] && printf " \033[00;37m[%s]\033[00m" "$branch" +[ -n "$branch" ] && printf " \033[38;5;250m[%s]\033[00m" "$branch" if [ -n "$model" ]; then effort=$(echo "$input" | jq -r ".effort.level // empty") - [ -z "$effort" ] && effort=$(jq -r '.effortLevel // empty' ~/.claude/settings.json 2>/dev/null) + # Сохраняем effort для persistence между сессиями одного лаунчера + if [ -n "$effort" ] && [ -n "${AI_LAUNCHER:-}" ]; then + effort_file="$HOME/.cache/ai-setup/effort_${AI_LAUNCHER}" + prev_effort=$(cat "$effort_file" 2>/dev/null) + if [ "$effort" != "$prev_effort" ]; then + mkdir -p "$HOME/.cache/ai-setup" + echo "$effort" > "$effort_file" + fi + fi # Аккаунт Claude.ai актуален только для нативных моделей Claude if [[ "$model_id" == claude-* ]]; then account=$(cat ~/.claude/accounts/current 2>/dev/null) @@ -58,12 +79,13 @@ if [ -n "$model" ]; then fi fi fi - [ -n "$account" ] && printf " \033[38;5;173m[%s]\033[00m" "$account" + [ -n "$account" ] && printf " \033[38;5;223m[%s]\033[00m" "$account" fi if [ -n "$effort" ]; then - printf " \033[38;5;173m%s [%s]\033[00m" "$model" "$effort" + printf " \033[38;5;223m%s " "$model" + _effort_color "$effort" else - printf " \033[38;5;173m%s\033[00m" "$model" + printf " \033[38;5;223m%s\033[00m" "$model" fi fi @@ -90,21 +112,22 @@ fmt_remaining() { pct_color() { local pct="$1" if [ "$pct" -lt 40 ]; then - printf '\033[00;32m' + printf '\033[38;5;114m' # мягкий зелёный elif [ "$pct" -lt 60 ]; then - printf '\033[00;33m' + printf '\033[38;5;221m' # золотистый else - printf '\033[00;31m' + printf '\033[38;5;210m' # мягкий красный fi } + # --- Баланс DeepSeek --- # Моментально показываем кэшированный баланс, в фоне обновляем через API. if [[ "$model_id" == *deepseek* ]]; then cache_file="$HOME/.cache/ai-setup/deepseek_balance" if [ -f "$cache_file" ]; then balance=$(head -1 "$cache_file") - [ -n "$balance" ] && printf " \033[00;35m\$%s\033[00m" "$balance" + [ -n "$balance" ] && printf " \033[38;5;147m%s\033[00m" "$balance" fi # Фоновое обновление баланса (не чаще раза в 30 секунд) @@ -125,10 +148,15 @@ if [[ "$model_id" == *deepseek* ]]; then import sys, json d = json.load(sys.stdin) infos = d.get('balance_infos', []) -if infos: - curr = infos[0].get('currency', '') - total = infos[0].get('total_balance', '0') - print(f'{total} {curr}') +symbols = {'USD': '\$', 'CNY': '\u00a5'} +parts = [] +for info in infos: + curr = info.get('currency', '') + total = info.get('total_balance', '0') + sym = symbols.get(curr, curr) + parts.append(f'{sym}{total}') +if parts: + print(' '.join(parts)) " 2>/dev/null) if [ -n "$new_balance" ]; then echo "$new_balance" > "$cache_file"