Skip to content

Instantly share code, notes, and snippets.

@lukehedger
Last active February 25, 2026 13:12
Show Gist options
  • Select an option

  • Save lukehedger/506b5f95f417dc9920063b548e28e449 to your computer and use it in GitHub Desktop.

Select an option

Save lukehedger/506b5f95f417dc9920063b548e28e449 to your computer and use it in GitHub Desktop.
Claude Code custom status line

Claude Code Custom Status Line

A custom status line that shows session info: model, context usage, and cost.

opus-4-6 | 12% | $0.04
  • Model (blue) — shortened model name
  • Context (yellow) — percentage of context window used
  • Cost (green) — session cost in USD
image

Prerequisites

  • jq installed (brew install jq on macOS)

Setup

1. Create the script

Create ~/.claude/statusline-command.sh:

#!/bin/bash
input=$(cat)

model=$(echo "$input" | jq -r '.model.display_name | sub("^anthropic\\.claude-";"") | sub("-v[0-9]+$";"")')
ctx=$(echo "$input" | jq -r '.context_window.used_percentage // 0')
cost=$(echo "$input" | jq -r '.cost.total_cost_usd')

cost_fmt=$(printf "%.2f" "$cost")

printf "\033[34m%s\033[0m \033[2m|\033[0m \033[33m%s%%\033[0m \033[2m|\033[0m \033[32m\$%s\033[0m" "$model" "$ctx" "$cost_fmt"

Make it executable:

chmod +x ~/.claude/statusline-command.sh

2. Configure Claude Code

Add the statusLine entry to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/statusline-command.sh"
  }
}

That's it. The status line appears at the bottom of the Claude Code terminal.

How it works

Claude Code pipes a JSON object to the status line command's stdin on each refresh. The script extracts three fields:

Field JSON path Description
Model .model.display_name Active model, trimmed to short name (e.g. opus-4-6)
Context .context_window.used_percentage Percentage of context window consumed
Cost .cost.total_cost_usd Cumulative session cost in USD

Customisation

Colors

The ANSI escape codes in the printf control colors. Change them to suit your terminal theme:

Code Color
\033[31m Red
\033[32m Green
\033[33m Yellow
\033[34m Blue
\033[35m Magenta
\033[36m Cyan
\033[1m Bold
\033[2m Dim

Available fields

The full JSON input includes:

{
  "session_id": "...",
  "cwd": "/path/to/project",
  "model": { "id": "...", "display_name": "..." },
  "version": "2.1.39",
  "cost": {
    "total_cost_usd": 3.10,
    "total_duration_ms": 80201764,
    "total_api_duration_ms": 545739,
    "total_lines_added": 106,
    "total_lines_removed": 38
  },
  "context_window": {
    "used_percentage": 19,
    "remaining_percentage": 81,
    "context_window_size": 200000
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment