feat: обновить цвета статусной строки

- путь и ветка: светло-серый (37), как хинты Claude Code
- модель: приглушённый лососевый (173), фирменный цвет Claude
- лимиты и ctx: единая функция pct_color (зелёный/жёлтый/красный)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 00:28:49 +03:00
parent c9db0be030
commit 0b0d51b77c

View File

@@ -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) branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null)
short_cwd="${cwd/#$HOME/\~}" 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 "$branch" ] && printf " \033[00;37m[%s]\033[00m" "$branch"
[ -n "$model" ] && printf " \033[00;36m%s\033[00m" "$model" [ -n "$model" ] && printf " \033[38;5;173m%s\033[00m" "$model"
# Форматирует оставшееся время до сброса лимита # Форматирует оставшееся время до сброса лимита
fmt_remaining() { fmt_remaining() {
@@ -35,6 +35,18 @@ fmt_remaining() {
fi 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 if [[ "$model" == *[Dd]eep[Ss]eek* ]]; then
cache_file="$HOME/.cache/ai-setup/deepseek_balance" cache_file="$HOME/.cache/ai-setup/deepseek_balance"
if [ -f "$cache_file" ]; then if [ -f "$cache_file" ]; then
@@ -43,25 +55,23 @@ if [[ "$model" == *[Dd]eep[Ss]eek* ]]; then
fi fi
else else
if [ -n "$five_pct" ] && [ -n "$five_reset" ]; then if [ -n "$five_pct" ] && [ -n "$five_reset" ]; then
five_int=$(printf '%.0f' "$five_pct")
remaining=$(fmt_remaining "$five_reset") 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 fi
if [ -n "$week_pct" ] && [ -n "$week_reset" ]; then if [ -n "$week_pct" ] && [ -n "$week_reset" ]; then
week_int=$(printf '%.0f' "$week_pct")
remaining=$(fmt_remaining "$week_reset") 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
fi fi
if [ -n "$ctx_pct" ]; then if [ -n "$ctx_pct" ]; then
ctx_int=$(printf '%.0f' "$ctx_pct") ctx_int=$(printf '%.0f' "$ctx_pct")
if [ "$ctx_int" -lt 40 ]; then color=$(pct_color "$ctx_int")
ctx_color="\033[00;32m" printf " %sctx:%s%%\033[00m" "$color" "$ctx_int"
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"
# Звуковой сигнал при первом достижении 60% # Звуковой сигнал при первом достижении 60%
alert_file="$HOME/.cache/ai-setup/ctx_alert_state" alert_file="$HOME/.cache/ai-setup/ctx_alert_state"