#!/bin/bash # Claude Code Status Line Script # This script receives JSON input via stdin and formats the status line # Read JSON input from stdin input=$(cat) # Debug: Save input to file for inspection echo "$input" > /tmp/statusline-debug.json # Extract relevant information model=$(echo "$input" | jq -r '.model.display_name // "unknown"') used_percentage=$(echo "$input" | jq -r '.context_window.used_percentage // 0') input_tokens=$(echo "$input" | jq -r '.context_window.current_usage.input_tokens // 0') output_tokens=$(echo "$input" | jq -r '.context_window.current_usage.output_tokens // 0') used_tokens=$((input_tokens + output_tokens)) total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 0') branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "no-git") project=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "workspace") # Create progress bar (20 characters wide) bar_width=20 filled=$((used_percentage * bar_width / 100)) empty=$((bar_width - filled)) progress_bar="[" for ((i = 0; i < filled; i++)); do progress_bar+="=" done for ((i = 0; i < empty; i++)); do progress_bar+=" " done progress_bar+="]" # Format output with colors # Magenta for model, Green for progress bar, Yellow for percentage, Cyan for tokens, Blue for branch, White for project printf "\033[35m%s\033[0m %s \033[33m%d%%\033[0m \033[36m%d/%d\033[0m \033[34m%s\033[0m \033[37m%s\033[0m" \ "$model" "$progress_bar" "$used_percentage" "$used_tokens" "$total_tokens" "$branch" "$project"