diff --git a/home-configs/claude/statusline-command.sh b/home-configs/claude/statusline-command.sh index aaefb98..ad1b1d9 100644 --- a/home-configs/claude/statusline-command.sh +++ b/home-configs/claude/statusline-command.sh @@ -11,10 +11,10 @@ ctx_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null) short_cwd="${cwd/#$HOME/\~}" -printf "\033[01;34m%s\033[00m" "$short_cwd" +printf "\033[00;37m%s\033[00m" "$short_cwd" -[ -n "$branch" ] && printf " \033[01;33m[%s]\033[00m" "$branch" -[ -n "$model" ] && printf " \033[00;36m%s\033[00m" "$model" +[ -n "$branch" ] && printf " \033[00;37m[%s]\033[00m" "$branch" +[ -n "$model" ] && printf " \033[38;5;173m%s\033[00m" "$model" # Форматирует оставшееся время до сброса лимита fmt_remaining() { @@ -35,6 +35,18 @@ fmt_remaining() { fi } +# Возвращает ANSI-цвет по проценту: зелёный <40%, жёлтый 40-60%, красный >=60% +pct_color() { + local pct="$1" + if [ "$pct" -lt 40 ]; then + printf '\033[00;32m' + elif [ "$pct" -lt 60 ]; then + printf '\033[00;33m' + else + printf '\033[00;31m' + fi +} + if [[ "$model" == *[Dd]eep[Ss]eek* ]]; then cache_file="$HOME/.cache/ai-setup/deepseek_balance" if [ -f "$cache_file" ]; then @@ -43,25 +55,23 @@ if [[ "$model" == *[Dd]eep[Ss]eek* ]]; then fi else if [ -n "$five_pct" ] && [ -n "$five_reset" ]; then + five_int=$(printf '%.0f' "$five_pct") remaining=$(fmt_remaining "$five_reset") - printf " \033[00;35m%s:$(printf '%.0f' "$five_pct")%%\033[00m" "$remaining" + color=$(pct_color "$five_int") + printf " %s%s:%s%%\033[00m" "$color" "$remaining" "$five_int" fi if [ -n "$week_pct" ] && [ -n "$week_reset" ]; then + week_int=$(printf '%.0f' "$week_pct") remaining=$(fmt_remaining "$week_reset") - printf " \033[00;35m%s:$(printf '%.0f' "$week_pct")%%\033[00m" "$remaining" + color=$(pct_color "$week_int") + printf " %s%s:%s%%\033[00m" "$color" "$remaining" "$week_int" fi fi if [ -n "$ctx_pct" ]; then ctx_int=$(printf '%.0f' "$ctx_pct") - if [ "$ctx_int" -lt 40 ]; then - ctx_color="\033[00;32m" - elif [ "$ctx_int" -lt 60 ]; then - ctx_color="\033[00;33m" - else - ctx_color="\033[00;31m" - fi - printf " ${ctx_color}ctx:${ctx_int}%%\033[00m" + color=$(pct_color "$ctx_int") + printf " %sctx:%s%%\033[00m" "$color" "$ctx_int" # Звуковой сигнал при первом достижении 60% alert_file="$HOME/.cache/ai-setup/ctx_alert_state"