DEV Community

Cover image for ๐Ÿข and ๐Ÿ‡ in My Claude Code Status Line
yukihiro amadatsu
yukihiro amadatsu

Posted on

๐Ÿข and ๐Ÿ‡ in My Claude Code Status Line

The Claude Code status line gives you a JSON blob and lets you render whatever you want. Docs here. I made mine an Aesop's fable โ€” borrowing the idea from Rabbit, a presentation tool by Kouhei Sutou that famously races a rabbit against a tortoise to show whether you're on pace.

[Sonnet 4.6] ยทยทยทยทยทยทยทยท๐Ÿขยทยทยทยท๐Ÿ‡ยทยทยทยทยทยทยท 5h:62% โš ๏ธ | reset 18:00 | 7d:23%
Enter fullscreen mode Exit fullscreen mode
  • ๐Ÿข = where you should be (time elapsed in the 5-hour window).
  • ๐Ÿ‡ = where you actually are (tokens used).
  • โš ๏ธ = hare is ahead, you're burning too fast.

The point: a raw "62%" means opposite things at hour 1 vs hour 4. Comparing actual pace to ideal pace is what I actually want to know โ€” and the tortoise/hare visual does it at a glance, no mental math.

The script

#!/bin/bash
input=$(cat)

MODEL=$(echo "$input" | jq -r '.model.display_name')
FIVE_H_PCT=$(echo "$input" | jq -r '(.rate_limits.five_hour.used_percentage // 0)')
SEVEN_D_PCT=$(echo "$input" | jq -r '(.rate_limits.seven_day.used_percentage // 0) * 10 | floor | . / 10')
RESETS_AT=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')

if [ -n "$RESETS_AT" ]; then
    REMAINING_SEC=$((RESETS_AT - $(date +%s)))
    RESET_JST=$(TZ=Asia/Tokyo date -r "$RESETS_AT" "+%H:%M")
    RESET_STR=" | reset ${RESET_JST}"
    if [ "$REMAINING_SEC" -gt 0 ] && [ "$REMAINING_SEC" -lt 18000 ]; then
        IDEAL_PCT=$(( (18000 - REMAINING_SEC) * 100 / 18000 ))
    else
        IDEAL_PCT=0
    fi
else
    IDEAL_PCT=0; RESET_STR=""
fi

BAR_WIDTH=20
ACTUAL_POS=$(awk "BEGIN {print int($FIVE_H_PCT * $BAR_WIDTH / 100)}")
IDEAL_POS=$((IDEAL_PCT * BAR_WIDTH / 100))

BAR=""
for i in $(seq 0 $((BAR_WIDTH - 1))); do
    if [ "$i" -eq "$IDEAL_POS" ] && [ "$i" -eq "$ACTUAL_POS" ]; then
        BAR="${BAR}๐Ÿข๐Ÿ‡"
    elif [ "$i" -eq "$IDEAL_POS" ]; then BAR="${BAR}๐Ÿข"
    elif [ "$i" -eq "$ACTUAL_POS" ]; then BAR="${BAR}๐Ÿ‡"
    else BAR="${BAR}ยท"
    fi
done

[ "$ACTUAL_POS" -gt "$IDEAL_POS" ] && WARN=" โš ๏ธ" || WARN=""
FIVE_H_DISP=$(echo "$FIVE_H_PCT" | awk '{printf "%.0f", $1}')
echo "[$MODEL] ${BAR} 5h:${FIVE_H_DISP}%${WARN}${RESET_STR} | 7d:${SEVEN_D_PCT}%"
Enter fullscreen mode Exit fullscreen mode

18000 is 5 hours in seconds. Drop TZ=Asia/Tokyo for your local zone.

Install

Save as ~/.claude/statusline.sh, chmod +x it, then in ~/.claude/settings.json:

{
  "statusLine": { "type": "command", "command": "~/.claude/statusline.sh" }
}
Enter fullscreen mode Exit fullscreen mode

Restart Claude Code. Done.


The rabbit-vs-tortoise pacing metaphor is lifted straight from Rabbit (ใ†ใ•ใŽใจใ‹ใ‚). Same idea, different domain โ€” slide timer โ†’ token budget.

Top comments (0)