Skip to content

Instantly share code, notes, and snippets.

@gatopeich
Created January 30, 2026 09:45
Show Gist options
  • Select an option

  • Save gatopeich/89e1bbb0d529a9b5bd78253c1109a468 to your computer and use it in GitHub Desktop.

Select an option

Save gatopeich/89e1bbb0d529a9b5bd78253c1109a468 to your computer and use it in GitHub Desktop.
Claude Code status line script - shows CWD, model, context %, cost, API time, and tmux pane title
#!/bin/bash
# Claude Code Status Line Script
# Shows: CWD (cyan), Model ID (orange), Context Usage (blue), Money Spent (yellow), API Response Time (green)
# Enable debugging by setting DEBUG_STATUSLINE=1
DEBUG=${DEBUG_STATUSLINE:-0}
# Color codes
CYAN='\033[36m'
ORANGE='\033[38;5;208m'
BLUE='\033[34m'
YELLOW='\033[93m'
GREEN='\033[32m'
MAGENTA='\033[35m'
PURPLE='\033[38;5;177m'
RESET='\033[0m'
# Read JSON input from stdin
input=$(cat)
# Write input to temp file
echo "$input" > /tmp/claude-status.json
# echo $input
debug() {
[[ $DEBUG ]] && echo "DEBUG: $*" >&2
}
debug "Raw input: $input"
jq_r() {
echo "$input" | jq -r "$1"
}
cwd=$(jq_r '.cwd')
debug "Current working directory: $cwd"
cwd=$(basename "$cwd")
# Extract basic fields with fallbacks
model_id=$(jq_r '.model.id // .model.display_name // -333')
debug "Model ID: $model_id"
# Extract context usage
context_pct=$(jq_r '.context_window.used_percentage // 0' | cut -d. -f1)
money_spent=$(jq_r '.cost.total_cost_usd // -333')
debug "Money spent: $money_spent"
# Try various response time field names
api_time=$(jq_r '.cost.total_api_duration_ms // -333')
debug "Extracted - CWD: $cwd, Model: $model_id, Context: $context_formatted, Money: $money_spent, Time: $api_time"
# Format API time as minutes:seconds
total_seconds=$((api_time / 1000))
minutes=$((total_seconds / 60))
seconds=$((total_seconds % 60))
time_formatted="${minutes}m ${seconds}s"
# Output the formatted status line
printf "${CYAN}%s${RESET} | ${MAGENTA}%s${RESET} | ${PURPLE}%s%%${RESET} | ${YELLOW}\$%.2f${RESET} for ${GREEN}%s${RESET}" \
"$cwd/" "$model_id" "$context_pct" "$money_spent" "$time_formatted"
# Get pane title from tmux
pane_title=$(tmux display-message -p '#{pane_title}' 2>/dev/null)
if [[ -n "$pane_title" ]]; then
printf " | ${ORANGE}%s${RESET}" "$pane_title"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment