Skip to content

Instantly share code, notes, and snippets.

@jtomaszon
Created January 25, 2026 16:08
Show Gist options
  • Select an option

  • Save jtomaszon/33cd561b7eed58b77f6ae8550585582f to your computer and use it in GitHub Desktop.

Select an option

Save jtomaszon/33cd561b7eed58b77f6ae8550585582f to your computer and use it in GitHub Desktop.
Claude Code statusline - screenrc-style footer with model, tokens, context %, lines changed, duration, git branch, path, cost

Claude Code Status Line

A screenrc-style status footer for Claude Code showing real-time session data.

Preview

[Opus] 14% | ↓28.5K ↑8.2K/200.0K | +156 -23 | 14m07s | main | myproject/src | $0.08

What it shows

Element Description
[Opus] Current model (cyan)
14% Context window usage (green/yellow/red based on %)
↓28.5K ↑8.2K Input/output tokens (magenta)
/200.0K Context window size
+156 -23 Lines added (green) / removed (red)
14m07s Session duration
main Git branch (green)
myproject/src Current path - last 2 dirs (blue)
$0.08 Session cost (yellow)

Installation

  1. Save statusline.sh to ~/.claude/statusline.sh

  2. Make it executable:

    chmod +x ~/.claude/statusline.sh
  3. Add to ~/.claude/settings.json:

    {
      "statusLine": {
        "type": "command",
        "command": "~/.claude/statusline.sh",
        "padding": 0
      }
    }
  4. Restart Claude Code (or it may auto-reload)

Requirements

  • jq (for JSON parsing)
  • bc (for math - usually pre-installed on macOS/Linux)

Customization

Edit the script to:

  • Change colors (ANSI codes at the bottom)
  • Remove/add fields (modify the OUTPUT lines)
  • Adjust path length (change cut -d'/' -f1-2 to show more/fewer dirs)

License

MIT - do whatever you want with it.

#!/bin/bash
# Claude Code Status Line - similar to screenrc footer
# Shows: [Model] Context% | tokens | +lines -lines | duration | branch | path | $cost
input=$(cat)
# Parse JSON input
MODEL=$(echo "$input" | jq -r '.model.display_name // "Claude"')
PERCENT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | xargs printf "%.0f")
DIR=$(echo "$input" | jq -r '.workspace.current_dir // ""')
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
INPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
OUTPUT_TOKENS=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
CTX_SIZE=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')
LINES_ADDED=$(echo "$input" | jq -r '.cost.total_lines_added // 0')
LINES_REMOVED=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')
DURATION_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
# Format token counts (K for thousands)
format_tokens() {
local num=$1
if [ "$num" -ge 1000 ]; then
printf "%.1fK" "$(echo "scale=1; $num/1000" | bc)"
else
echo "$num"
fi
}
# Format duration (ms to human readable)
format_duration() {
local ms=$1
local secs=$((ms / 1000))
local mins=$((secs / 60))
local hours=$((mins / 60))
mins=$((mins % 60))
secs=$((secs % 60))
if [ "$hours" -gt 0 ]; then
printf "%dh%02dm" "$hours" "$mins"
elif [ "$mins" -gt 0 ]; then
printf "%dm%02ds" "$mins" "$secs"
else
printf "%ds" "$secs"
fi
}
IN_FMT=$(format_tokens "$INPUT_TOKENS")
OUT_FMT=$(format_tokens "$OUTPUT_TOKENS")
CTX_FMT=$(format_tokens "$CTX_SIZE")
DUR_FMT=$(format_duration "$DURATION_MS")
# Get git branch if in a repo
BRANCH=""
if [ -n "$DIR" ] && [ -d "$DIR" ]; then
BRANCH=$(git -C "$DIR" branch --show-current 2>/dev/null)
fi
# Shorten path for display (last 2 components)
SHORT_PATH=""
if [ -n "$DIR" ]; then
SHORT_PATH=$(echo "$DIR" | rev | cut -d'/' -f1-2 | rev)
fi
# Format cost (only show if > $0.001)
COST_STR=""
if (( $(echo "$COST > 0.001" | bc -l) )); then
COST_STR=$(printf "\$%.2f" "$COST")
fi
# ANSI colors
CYAN='\033[0;36m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
MAGENTA='\033[0;35m'
RED='\033[0;31m'
BLUE='\033[0;34m'
DIM='\033[2m'
RESET='\033[0m'
# Color context percentage based on usage
if [ "$PERCENT" -lt 50 ]; then
PCT_COLOR=$GREEN
elif [ "$PERCENT" -lt 80 ]; then
PCT_COLOR=$YELLOW
else
PCT_COLOR=$RED
fi
# Build output
OUTPUT="${CYAN}[${MODEL}]${RESET}"
OUTPUT="$OUTPUT ${PCT_COLOR}${PERCENT}%${RESET}"
OUTPUT="$OUTPUT ${DIM}|${RESET} ${MAGENTA}↓${IN_FMT} ↑${OUT_FMT}${RESET}${DIM}/${CTX_FMT}${RESET}"
OUTPUT="$OUTPUT ${DIM}|${RESET} ${GREEN}+${LINES_ADDED}${RESET} ${RED}-${LINES_REMOVED}${RESET}"
OUTPUT="$OUTPUT ${DIM}|${RESET} ${DIM}${DUR_FMT}${RESET}"
[ -n "$BRANCH" ] && OUTPUT="$OUTPUT ${DIM}|${RESET} ${GREEN}${BRANCH}${RESET}"
[ -n "$SHORT_PATH" ] && OUTPUT="$OUTPUT ${DIM}|${RESET} ${BLUE}${SHORT_PATH}${RESET}"
[ -n "$COST_STR" ] && OUTPUT="$OUTPUT ${DIM}|${RESET} ${YELLOW}${COST_STR}${RESET}"
echo -e "$OUTPUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment