From 6b80364344401c740372f74fa743ec953e3e0d58 Mon Sep 17 00:00:00 2001 From: vitaly Date: Sat, 6 Jun 2026 12:47:00 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D1=8C=20=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=B5=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D0=B4=D0=BE=20?= =?UTF-8?q?=D1=81=D0=B1=D1=80=D0=BE=D1=81=D0=B0=20=D0=BB=D0=B8=D0=BC=D0=B8?= =?UTF-8?q?=D1=82=D0=B0=20=D0=B2=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Вместо захардкоженного "5h" теперь считается оставшееся время из resets_at timestamp: "4ч40м:25%", "58м:80%" и т.д. Co-Authored-By: Claude Sonnet 4.6 --- home-configs/claude/statusline-command.sh | 34 ++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/home-configs/claude/statusline-command.sh b/home-configs/claude/statusline-command.sh index 572b14e..09627f2 100644 --- a/home-configs/claude/statusline-command.sh +++ b/home-configs/claude/statusline-command.sh @@ -3,7 +3,9 @@ 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') +five_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty') week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') +week_reset=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty') branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null) @@ -13,8 +15,32 @@ printf "\033[01;34m%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" -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" +# Форматирует оставшееся время до сброса лимита +fmt_remaining() { + local reset_ts="$1" + local now + now=$(date +%s) + local diff=$(( reset_ts - now )) + [ "$diff" -le 0 ] && echo "скоро" && return + local h=$(( diff / 3600 )) + local m=$(( (diff % 3600) / 60 )) + if [ "$h" -gt 0 ]; then + echo "${h}ч${m}м" + else + echo "${m}м" + fi +} + +if [[ "$model" == *[Dd]eep[Ss]eek* ]]; 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" + fi +elif [ -n "$five_pct" ] && [ -n "$five_reset" ]; then + remaining=$(fmt_remaining "$five_reset") + printf " \033[00;35m%s:$(printf '%.0f' "$five_pct")%%\033[00m" "$remaining" +elif [ -n "$week_pct" ] && [ -n "$week_reset" ]; then + remaining=$(fmt_remaining "$week_reset") + printf " \033[00;35m%s:$(printf '%.0f' "$week_pct")%%\033[00m" "$remaining" fi