Loading...
Feature-rich statusline using Python's Rich library for beautiful formatting, progress bars, and real-time token cost tracking
#!/usr/bin/env python3
import sys
import json
from rich.console import Console
from rich.text import Text
console = Console()
# Read JSON from stdin
try:
data = json.load(sys.stdin)
except json.JSONDecodeError:
console.print("[red]Error: Invalid JSON input[/red]")
sys.exit(1)
# Extract session data
model = data.get('model', 'unknown')
workspace = data.get('workspace', {}).get('path', '~').replace(f"{os.path.expanduser('~')}", '~')
tokens = data.get('session', {}).get('totalTokens', 0)
cost = data.get('session', {}).get('estimatedCost', 0.0)
git_branch = data.get('git', {}).get('branch', None)
# Build status components
status = Text()
# Model indicator with emoji
status.append("🤖 ", style="bold")
status.append(f"{model}", style="bold cyan")
status.append(" │ ", style="dim")
# Directory
status.append("📁 ", style="bold")
status.append(f"{workspace}", style="yellow")
# Git branch if available
if git_branch:
status.append(" │ ", style="dim")
status.append(" ", style="bold")
status.append(f"{git_branch}", style="magenta")
# Token usage
status.append(" │ ", style="dim")
status.append("🎯 ", style="bold")
status.append(f"{tokens:,}", style="green" if tokens < 100000 else "yellow")
# Cost with dynamic coloring
if cost > 0:
status.append(" │ ", style="dim")
status.append("💰 ", style="bold")
cost_color = "green" if cost < 0.10 else "yellow" if cost < 1.0 else "red"
status.append(f"${cost:.3f}", style=cost_color)
console.print(status)
{
"format": "python",
"position": "left",
"colorScheme": "rich-default",
"refreshInterval": 1000
}ModuleNotFoundError: No module named 'rich'
Install the Rich library: pip3 install rich or python3 -m pip install rich
Emojis displaying as boxes or not rendering
Ensure terminal supports Unicode emojis. Use iTerm2, Kitty, or Windows Terminal. Test with: python3 -c 'print("🤖 Test")'
Colors look washed out or incorrect
Enable truecolor support. Set COLORTERM=truecolor environment variable or use a terminal that supports 24-bit color.
Script execution too slow
Rich has some startup overhead. Consider increasing refreshInterval to 2000-3000ms or use the minimal-powerline statusline instead.
Loading reviews...