|
288 | 288 |
|
289 | 289 | # Rate limits (requires Claude Code 2.1.80+) |
290 | 290 | if [ "$SHOW_RATE_LIMITS" = true ]; then |
291 | | - rl_5h=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty') |
292 | | - rl_7d=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') |
| 291 | + rl_5h=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty | (. * 100 | round) / 100') |
| 292 | + rl_7d=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty | (. * 100 | round) / 100') |
293 | 293 |
|
294 | 294 | if [ -n "$rl_5h" ] && [ -n "$rl_7d" ]; then |
295 | | - if [ "$rl_5h" -lt 50 ]; then rl_5h_color='32' |
296 | | - elif [ "$rl_5h" -lt 80 ]; then rl_5h_color='33' |
| 295 | + rl_5h_int=${rl_5h%%.*} |
| 296 | + rl_7d_int=${rl_7d%%.*} |
| 297 | + |
| 298 | + if [ "$rl_5h_int" -lt 50 ]; then rl_5h_color='32' |
| 299 | + elif [ "$rl_5h_int" -lt 80 ]; then rl_5h_color='33' |
297 | 300 | else rl_5h_color='31'; fi |
298 | 301 |
|
299 | | - if [ "$rl_7d" -lt 50 ]; then rl_7d_color='32' |
300 | | - elif [ "$rl_7d" -lt 80 ]; then rl_7d_color='33' |
| 302 | + if [ "$rl_7d_int" -lt 50 ]; then rl_7d_color='32' |
| 303 | + elif [ "$rl_7d_int" -lt 80 ]; then rl_7d_color='33' |
301 | 304 | else rl_7d_color='31'; fi |
302 | 305 |
|
303 | 306 | [ -n "$output" ] && output="$output · " |
@@ -503,15 +506,15 @@ if ($SHOW_RATE_LIMITS) { |
503 | 506 | $rl_parts = @() |
504 | 507 |
|
505 | 508 | if ($null -ne $rl.five_hour) { |
506 | | - $rl_5h = [int]$rl.five_hour.used_percentage |
| 509 | + $rl_5h = [math]::Round($rl.five_hour.used_percentage, 2) |
507 | 510 | if ($rl_5h -lt 50) { $rl_5h_color = $green } |
508 | 511 | elseif ($rl_5h -lt 80) { $rl_5h_color = $yellow } |
509 | 512 | else { $rl_5h_color = $red } |
510 | 513 | $rl_parts += "${rl_5h_color}5h:${rl_5h}%$reset" |
511 | 514 | } |
512 | 515 |
|
513 | 516 | if ($null -ne $rl.seven_day) { |
514 | | - $rl_7d = [int]$rl.seven_day.used_percentage |
| 517 | + $rl_7d = [math]::Round($rl.seven_day.used_percentage, 2) |
515 | 518 | if ($rl_7d -lt 50) { $rl_7d_color = $green } |
516 | 519 | elseif ($rl_7d -lt 80) { $rl_7d_color = $yellow } |
517 | 520 | else { $rl_7d_color = $red } |
|
0 commit comments