Skip to content

Instantly share code, notes, and snippets.

@Mohamed3on
Last active December 19, 2025 11:05
Show Gist options
  • Select an option

  • Save Mohamed3on/70780575570a07985916e5f50e290382 to your computer and use it in GitHub Desktop.

Select an option

Save Mohamed3on/70780575570a07985916e5f50e290382 to your computer and use it in GitHub Desktop.
Claude Code statusline with colors, token usage, cost, and more

Claude Code Statusline

A colorful, informative statusline for Claude Code CLI with powerline-style separators.

Features

  • Directory (blue) - Current working directory
  • Node version (green ⬢) - Shows when package.json exists
  • Session duration (cyan ⏱) - How long you've been working
  • Lines changed - Net indicator (▲/▼/=) with +added/-removed
  • Token usage - Progress bar (▓░) with percentage, color-coded by usage
  • Cost - Session cost with thresholds (green < $2, yellow $2-10, red > $10)
  • Model - Tier indicator (◆ Opus, ◇ Sonnet, ○ Haiku)

Example Output

apeye-service  ⬢ 20.14.0  ⏱ 12m  ▲ +150 -30  ▓▓░░░░░░ 25%  $2.50  ◆ Opus

Color Meanings

Element Green Yellow Red
Lines Net positive (▲) - Net negative (▼)
Tokens < 50% 50-75% > 75%
Cost < $2 $2-10 > $10

Installation

  1. Download the script to ~/.claude/:
curl -o ~/.claude/statusline.sh https://gist.githubusercontent.com/Mohamed3on/70780575570a07985916e5f50e290382/raw/statusline.sh
chmod +x ~/.claude/statusline.sh
  1. Add to your ~/.claude/settings.json:
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh"
  }
}

Requirements

  • jq - for parsing JSON input
  • bc - for cost calculations (usually pre-installed)
  • node - for Node version display (optional)

Customization

Edit ~/.claude/statusline.sh to customize:

  • Color thresholds
  • Which segments to show/hide
  • Progress bar width and characters
  • Symbols and formatting

Compatibility

Uses basic ANSI color codes (31-36, 90) for maximum terminal compatibility. Tested with:

  • macOS Terminal
  • iTerm2
  • Cursor integrated terminal
  • VS Code terminal

License

MIT

Claude Code Statusline

A colorful, informative statusline for Claude Code CLI.

statusline

Features

  • Directory (blue) - Current working directory
  • Node version (green ⬢) - Shows when package.json exists
  • Session duration (cyan ⏱) - How long you've been working
  • Lines changed - Net indicator (▲/▼/●) with +added/-removed
  • Token usage - Visual fill indicator (◔◑◕●⚠) with smart colors
  • Cost - Session cost with thresholds (green < $2, yellow $2-10, red > $10)
  • Model - Tier indicator (◆ Opus, ◇ Sonnet, ○ Haiku)

Example Output

technoland │ ⬢ 20.14.0 │ ⏱ 12m30s │ ▲ +128 -51 │ ◔ 35k/200k │ $2.50 │ ◆ Opus 4.5

Installation

  1. Download the script to ~/.claude/:
curl -o ~/.claude/statusline.sh https://gist.githubusercontent.com/Mohamed3on/70780575570a07985916e5f50e290382/raw/statusline.sh
chmod +x ~/.claude/statusline.sh
  1. Add to your ~/.claude/settings.json:
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh"
  }
}

Or if you have existing settings, just add the statusLine block.

Requirements

  • jq - for parsing JSON input
  • tput - for colors (usually pre-installed)
  • bc - for cost calculations (usually pre-installed)
  • node - for Node version display (optional)

Customization

Edit ~/.claude/statusline.sh to customize:

  • Color thresholds
  • Which segments to show/hide
  • Symbols and formatting

License

MIT

#!/bin/bash
export TERM=xterm-256color
input=$(cat)
cwd=$(echo "$input" | jq -r '.workspace.current_dir')
model=$(echo "$input" | jq -r '.model.display_name // empty')
# Token usage
input_tokens=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
output_tokens=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
context_limit=$(echo "$input" | jq -r '.context_window.context_window_size // 0')
total_tokens=$((input_tokens + output_tokens))
# Cost & stats
cost=$(echo "$input" | jq -r '.cost.total_cost_usd // empty')
duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
lines_added=$(echo "$input" | jq -r '.cost.total_lines_added // 0')
lines_removed=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')
# Colors - basic ANSI codes compatible with most terminals
RED=$'\033[31m'
GREEN=$'\033[32m'
YELLOW=$'\033[33m'
BLUE=$'\033[34m'
MAGENTA=$'\033[35m'
CYAN=$'\033[36m'
GRAY=$'\033[90m'
RESET=$'\033[0m'
SEP="${GRAY}${RESET}"
short_dir=$(basename "$cwd")
# Node version (only if package.json exists)
node_info=""
if [ -f "$cwd/package.json" ] 2>/dev/null; then
node_ver=$(node -v 2>/dev/null | sed 's/v//')
[ -n "$node_ver" ] && node_info=" ${SEP} ${GREEN}⬢ ${node_ver}${RESET}"
fi
# Session duration
duration_info=""
if [ "$duration_ms" -gt 0 ] 2>/dev/null; then
duration_sec=$((duration_ms / 1000))
if [ "$duration_sec" -ge 3600 ]; then
hours=$((duration_sec / 3600))
mins=$(((duration_sec % 3600) / 60))
duration_fmt="${hours}h${mins}m"
elif [ "$duration_sec" -ge 60 ]; then
mins=$((duration_sec / 60))
duration_fmt="${mins}m"
else
duration_fmt="${duration_sec}s"
fi
duration_info=" ${SEP} ${CYAN}⏱ ${duration_fmt}${RESET}"
fi
# Lines changed
lines_info=""
if [ "$lines_added" -gt 0 ] || [ "$lines_removed" -gt 0 ] 2>/dev/null; then
net=$((lines_added - lines_removed))
if [ "$net" -gt 0 ]; then
net_symbol="${GREEN}▲${RESET}"
elif [ "$net" -lt 0 ]; then
net_symbol="${RED}▼${RESET}"
else
net_symbol="${GRAY}=${RESET}"
fi
lines_info=" ${SEP} ${net_symbol} ${GREEN}+${lines_added}${RESET} ${RED}-${lines_removed}${RESET}"
fi
# Token usage with progress bar
token_info=""
if [ "$total_tokens" -gt 0 ] 2>/dev/null; then
if [ "$total_tokens" -ge 1000 ]; then
tokens_fmt="$((total_tokens / 1000))k"
else
tokens_fmt="$total_tokens"
fi
if [ "$context_limit" -gt 0 ] 2>/dev/null; then
pct=$((total_tokens * 100 / context_limit))
# Color based on usage
if [ "$pct" -ge 75 ]; then
bar_color="$RED"
elif [ "$pct" -ge 50 ]; then
bar_color="$YELLOW"
else
bar_color="$GREEN"
fi
# Build progress bar using simple chars: ▓ filled, ░ empty
bar_width=8
filled=$((pct * bar_width / 100))
[ "$filled" -gt "$bar_width" ] && filled=$bar_width
[ "$filled" -lt 1 ] && [ "$pct" -gt 0 ] && filled=1
empty=$((bar_width - filled))
bar="${bar_color}"
for ((i=0; i<filled; i++)); do bar+="▓"; done
bar+="${GRAY}"
for ((i=0; i<empty; i++)); do bar+="░"; done
bar+="${RESET}"
token_info=" ${SEP} ${bar} ${GRAY}${pct}%${RESET}"
fi
fi
# Cost with meaningful colors
cost_info=""
if [ -n "$cost" ] && [ "$cost" != "null" ]; then
cost_fmt=$(printf "%.2f" "$cost")
cost_cents=$(printf "%.0f" "$(echo "$cost * 100" | bc)")
if [ "$cost_cents" -ge 1000 ] 2>/dev/null; then
cost_color="$RED"
elif [ "$cost_cents" -ge 200 ] 2>/dev/null; then
cost_color="$YELLOW"
else
cost_color="$GREEN"
fi
cost_info=" ${SEP} ${cost_color}\$${cost_fmt}${RESET}"
fi
# Model with tier colors
model_info=""
if [ -n "$model" ]; then
case "$model" in
*Opus*) model_color="$MAGENTA"; model_symbol="◆"; short_model="Opus" ;;
*Sonnet*) model_color="$BLUE"; model_symbol="◇"; short_model="Sonnet" ;;
*Haiku*) model_color="$GREEN"; model_symbol="○"; short_model="Haiku" ;;
*) model_color="$GRAY"; model_symbol="●"; short_model="$model" ;;
esac
model_info=" ${SEP} ${model_color}${model_symbol} ${short_model}${RESET}"
fi
printf "${BLUE}${short_dir}${RESET}%s%s%s%s%s%s" "$node_info" "$duration_info" "$lines_info" "$token_info" "$cost_info" "$model_info"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment