docs: guard division by zero in script example

Add size > 0 check before computing context percentage to prevent
division by zero when context_window_size is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
wenshao 2026-04-06 18:46:15 +08:00
parent 12e1ef4594
commit 813d863e7c

View file

@ -135,7 +135,7 @@ branch=$(git branch --show-current 2>/dev/null)
parts=()
[ -n "$model" ] && parts+=("$model")
[ -n "$branch" ] && parts+=("($branch)")
if [ "$tokens" -gt 0 ] 2>/dev/null; then
if [ "$tokens" -gt 0 ] && [ "$size" -gt 0 ] 2>/dev/null; then
pct=$((tokens * 100 / size))
parts+=("ctx:${pct}%")
fi