This guide explains how to display Claude usage metrics in Claude Code's statusline using claude-o-meter.
Claude Code supports a customizable statusline that appears at the bottom of the terminal during conversations. You can configure it to show useful information like the current directory, git branch, model name, and—with claude-o-meter—your current usage metrics.
- claude-o-meter daemon running: The daemon must be running and writing to a JSON file
- jq (optional but recommended): For reliable JSON parsing in the statusline script
If using Home Manager:
services.claude-o-meter = {
enable = true;
# stateFile defaults to ~/.cache/claude-o-meter.json
};Or run manually:
claude-o-meter daemon -i 60s -f ~/.cache/claude-o-meter.json &Create a file at ~/.claude/statusline.sh:
#!/usr/bin/env bash
# See examples/statusline.sh for a complete example
input=$(cat)
# Parse claude-o-meter output
METER_FILE="$HOME/.cache/claude-o-meter.json"
if [ -f "$METER_FILE" ] && command -v claude-o-meter >/dev/null 2>&1; then
meter_json=$(claude-o-meter hyprpanel -f "$METER_FILE" 2>/dev/null)
meter_text=$(echo "$meter_json" | jq -r '.text // ""' 2>/dev/null)
if [ -n "$meter_text" ]; then
printf '⚡ %s\n' "$meter_text"
fi
fiMake it executable:
chmod +x ~/.claude/statusline.shAdd to your ~/.claude/settings.json:
{
"statusline": {
"script": "~/.claude/statusline.sh"
}
}Or with Home Manager:
programs.claude-code.settings = {
statusline.script = "~/.claude/statusline.sh";
};A complete sample statusline script is provided at examples/statusline.sh. It includes:
- Directory: Current working directory with home path abbreviation
- Git branch: Current git branch (if in a git repository)
- Model name: The Claude model being used
- Claude Code version: The version of Claude Code
- Usage metrics: Session usage percentage from claude-o-meter with color coding
- Color coding: Usage is displayed in green (low), orange (medium), or red (high) based on consumption
- jq fallback: Works without jq using bash-only JSON parsing (less reliable)
- Logging: Logs to
~/.claude/statusline.logfor debugging
📁 ~/projects/myapp 🌿 main 🤖 Claude Opus 4.5 📟 v2.0.76 ⚡ 45% Max (2h 30m)
The time in parentheses shows how long until the session quota resets.
Edit the color functions in the script. Colors use ANSI 256-color codes:
meter_low_color() { printf '\033[38;5;82m'; } # green
meter_medium_color() { printf '\033[38;5;214m'; } # orange
meter_high_color() { printf '\033[38;5;196m'; } # redIf you configured a custom stateFile in claude-o-meter, update the script:
METER_FILE="/your/custom/path.json"The statusline script receives JSON input from Claude Code with session information. Use jq to extract additional fields:
# Extract context usage percentage
context_pct=$(echo "$input" | jq -r '.context.percent_used // ""' 2>/dev/null)
# Extract session cost
cost=$(echo "$input" | jq -r '.cost.total_usd // ""' 2>/dev/null)- Check that the script is executable:
chmod +x ~/.claude/statusline.sh - Check that the path in
settings.jsonis correct - Test the script manually:
echo '{}' | ~/.claude/statusline.sh
- Verify the daemon is running:
systemctl --user status claude-o-meter - Check that the JSON file exists:
cat ~/.cache/claude-o-meter.json - Test claude-o-meter directly:
claude-o-meter hyprpanel -f ~/.cache/claude-o-meter.json
Check the statusline log file:
tail -f ~/.claude/statusline.logCheck daemon logs:
journalctl --user -u claude-o-meter -f