Skip to content

Instantly share code, notes, and snippets.

@froemken
Created July 23, 2026 21:22
Show Gist options
  • Select an option

  • Save froemken/4bca1e5e85aeae23ffc82c9b380dd89a to your computer and use it in GitHub Desktop.

Select an option

Save froemken/4bca1e5e85aeae23ffc82c9b380dd89a to your computer and use it in GitHub Desktop.
Statusline for Google Gemini Antigravity
#!/usr/bin/env python3
import sys
import json
import subprocess
def get_git_branch():
try:
res = subprocess.run(
['git', 'branch', '--show-current'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
timeout=1
)
branch = res.stdout.strip()
if branch:
return branch
except Exception:
pass
return "none"
def main():
try:
raw = sys.stdin.read()
data = json.loads(raw) if raw.strip() else {}
except Exception:
data = {}
# 1. Model Name
model_obj = data.get("model", {})
if isinstance(model_obj, dict):
model = model_obj.get("display_name") or model_obj.get("id") or "Gemini 3.6 Flash"
elif isinstance(model_obj, str) and model_obj.strip():
model = model_obj.strip()
else:
model = "Gemini 3.6 Flash"
# 2. Git Branch
branch = get_git_branch()
# 3. Session Tokens (total_input_tokens + total_output_tokens)
ctx = data.get("context_window", {})
total_in = ctx.get("total_input_tokens", 0)
total_out = ctx.get("total_output_tokens", 0)
session_tokens = total_in + total_out
# 4. Weekly Quota Used % (calculated from gemini-weekly remaining_fraction)
quota = data.get("quota", {})
gemini_weekly = quota.get("gemini-weekly", {})
rem_frac_weekly = gemini_weekly.get("remaining_fraction")
weekly_pct_str = None
if rem_frac_weekly is not None:
used_pct = (1.0 - float(rem_frac_weekly)) * 100.0
weekly_pct_str = f"{used_pct:.1f}%"
# 5. 5h Token Reset Countdown (from gemini-5h reset_in_seconds)
gemini_5h = quota.get("gemini-5h", {})
reset_sec = gemini_5h.get("reset_in_seconds")
time_reset = None
if reset_sec is not None:
sec = int(reset_sec)
hours = sec // 3600
mins = (sec % 3600) // 60
time_reset = f"{hours}h {mins:02d}m"
# Build statusline parts
parts = [
f"πŸ€– Model: {model}",
f"🌿 Branch: {branch}",
f"πŸ“Š Session Tokens: {session_tokens:,}"
]
if weekly_pct_str is not None:
parts.append(f"πŸ“ˆ Weekly Quota: {weekly_pct_str}")
if time_reset is not None:
parts.append(f"⏳ Reset in: {time_reset}")
print(" | ".join(parts))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment