Skip to content

Instantly share code, notes, and snippets.

@danslapman
Last active April 3, 2026 15:11
Show Gist options
  • Select an option

  • Save danslapman/fd82bd6b6d517c797900051fd71c37f8 to your computer and use it in GitHub Desktop.

Select an option

Save danslapman/fd82bd6b6d517c797900051fd71c37f8 to your computer and use it in GitHub Desktop.
My statusline
input=$(cat)
model=$(echo "$input" | jq -r '.model.display_name // "Unknown"')
five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
make_bar() {
local pct="$1"
local filled=$(awk "BEGIN { printf \"%.0f\", $pct * 10 / 100 }")
local empty=$((10 - filled))
local bar=""
local i
for ((i = 0; i < filled; i++)); do bar="${bar}█"; done
for ((i = 0; i < empty; i++)); do bar="${bar}░"; done
echo "$bar"
}
output="[PA] | $model"
five_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
if [ -n "$five_pct" ]; then
bar=$(make_bar "$five_pct")
pct_int=$(printf '%.0f' "$five_pct")
reset_str=""
if [ -n "$five_reset" ]; then
reset_str=" (resets $(date -d "@${five_reset}" +%H:%M 2>/dev/null || date -r "${five_reset}" +%H:%M 2>/dev/null))"
fi
output="$output | 5h: [${bar}] ${pct_int}%${reset_str}"
fi
if [ -n "$week_pct" ]; then
bar=$(make_bar "$week_pct")
pct_int=$(printf '%.0f' "$week_pct")
output="$output | 7d: [${bar}] ${pct_int}%"
fi
echo "$output"
input=$(cat)
model=$(echo "$input" | jq -r '.model.display_name // "Unknown"')
five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
make_bar() {
local pct="$1"
local filled=$(printf '%.0f' "$(echo "$pct * 10 / 100" | bc -l)")
local empty=$((10 - filled))
local bar=""
local i
for ((i = 0; i < filled; i++)); do bar="${bar}█"; done
for ((i = 0; i < empty; i++)); do bar="${bar}░"; done
echo "$bar"
}
output="$model"
five_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
if [ -n "$five_pct" ]; then
bar=$(make_bar "$five_pct")
pct_int=$(printf '%.0f' "$five_pct")
reset_str=""
if [ -n "$five_reset" ]; then
reset_str=" (resets $(date -d "@${five_reset}" +%H:%M 2>/dev/null || date -r "${five_reset}" +%H:%M 2>/dev/null))"
fi
output="$output | 5h: [${bar}] ${pct_int}%${reset_str}"
fi
if [ -n "$week_pct" ]; then
bar=$(make_bar "$week_pct")
pct_int=$(printf '%.0f' "$week_pct")
output="$output | 7d: [${bar}] ${pct_int}%"
fi
echo "$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment