Skip to content

Instantly share code, notes, and snippets.

@AmosG
AmosG / statusline.sh
Created March 6, 2026 21:18
Claude Code statusline: context window, session cost, and real-time 5h/7d plan rate limits via OAuth API
#!/bin/bash
input=$(cat)
MODEL=$(echo "$input" | jq -r '.model.display_name')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
# Context bar
BAR_WIDTH=10
FILLED=$((PCT * BAR_WIDTH / 100))