Skip to content

Instantly share code, notes, and snippets.

@7shi
Created March 28, 2026 19:00
Show Gist options
  • Select an option

  • Save 7shi/5a1e1b83fbe6c5c6b8114583d545a8ee to your computer and use it in GitHub Desktop.

Select an option

Save 7shi/5a1e1b83fbe6c5c6b8114583d545a8ee to your computer and use it in GitHub Desktop.
Claude Code's status line UI
import json, sys
from datetime import datetime, timezone
from pathlib import Path
data = json.load(sys.stdin)
RED = "\033[0;31m"
BLUE = "\033[01;34m"
YELLOW = "\033[0;33m"
CYAN = "\033[0;36m"
RESET = "\033[00m"
cwd = data.get("cwd") or "."
home = str(Path.home())
if cwd == home:
cwd = "~"
elif cwd.startswith(home + "/"):
cwd = "~" + cwd[len(home):]
parts = [f"{BLUE}{cwd}{RESET}"]
model = data.get("model", {}).get("display_name")
if model:
model = model.replace(" context", "")
parts.append(f"{YELLOW}{model}{RESET}")
used = data.get("context_window", {}).get("used_percentage")
if used is not None:
parts.append(f"{CYAN}ctx:{used:.0f}%{RESET}")
rl = data.get("rate_limits", {})
def parse_reset(val):
if isinstance(val, (int, float)):
return datetime.fromtimestamp(val, tz=timezone.utc).astimezone()
return datetime.fromisoformat(str(val)).astimezone()
five = rl.get("five_hour", {})
if five.get("used_percentage") is not None:
t = parse_reset(five["resets_at"])
parts.append(f"{YELLOW}5h:{five['used_percentage']:.0f}%({t:%H:%M}){RESET}")
seven = rl.get("seven_day", {})
if seven.get("used_percentage") is not None:
t = parse_reset(seven["resets_at"])
parts.append(f"{RED}7d:{seven['used_percentage']:.0f}%({t:%m/%d %H:%M}){RESET}")
print(" ".join(parts), end="")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment