Last active
December 19, 2025 21:13
-
-
Save morganmcg1/328d073b5b026ad50c597cf4ae9a85d8 to your computer and use it in GitHub Desktop.
Claude Code statusline settings - place in your ~/.claude/ dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "model": "opus", | |
| "statusLine": { | |
| "type": "command", | |
| "command": "~/.claude/statusline.sh" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Colors | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[0;33m' | |
| BLUE='\033[0;34m' | |
| MAGENTA='\033[0;35m' | |
| CYAN='\033[0;36m' | |
| WHITE='\033[0;37m' | |
| DIM='\033[2m' | |
| RESET='\033[0m' | |
| # Separator (minimal style) | |
| SEP="${DIM}β${RESET}" | |
| # Emoji icons (minimal) | |
| ICON_COST="π°" | |
| ICON_STYLE="π¨" | |
| # Read JSON input from stdin | |
| input=$(cat) | |
| # Helper functions for extracting data | |
| get_model_name() { echo "$input" | jq -r '.model.display_name // "Unknown Model"'; } | |
| # Get model-specific icon based on model name | |
| get_model_icon() { | |
| local model_name=$(get_model_name) | |
| case "$model_name" in | |
| *[Oo]pus*) echo "π" ;; # Theater masks for the dramatic, powerful model | |
| *[Ss]onnet*) echo "π΅" ;; # Musical note for the balanced, harmonious model | |
| *[Hh]aiku*) echo "π" ;; # Leaf for the light, quick model | |
| *) echo "π§ " ;; # Default brain icon | |
| esac | |
| } | |
| get_output_style() { echo "$input" | jq -r '.output_style.name // "default"'; } | |
| get_current_dir() { echo "$input" | jq -r '.workspace.current_dir // "."'; } | |
| get_project_dir() { echo "$input" | jq -r '.workspace.project_dir // "."'; } | |
| get_cost() { | |
| local cost=$(echo "$input" | jq -r '.cost.total_cost_usd // 0') | |
| printf "\$%.2f" "$cost" | |
| } | |
| get_context_percent() { | |
| local input_tokens=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0') | |
| local output_tokens=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0') | |
| local context_size=$(echo "$input" | jq -r '.context_window.context_window_size // 200000') | |
| local total_tokens=$((input_tokens + output_tokens)) | |
| local percent=$((total_tokens * 100 / context_size)) | |
| echo "$percent" | |
| } | |
| # Build a progress bar with color based on percentage | |
| build_context_bar() { | |
| local percent=$(get_context_percent) | |
| local bar_width=10 | |
| local filled=$((percent * bar_width / 100)) | |
| local empty=$((bar_width - filled)) | |
| # Cap filled at bar_width | |
| if [ "$filled" -gt "$bar_width" ]; then | |
| filled=$bar_width | |
| empty=0 | |
| fi | |
| # Choose color based on percentage thresholds | |
| local bar_color | |
| if [ "$percent" -lt 40 ]; then | |
| bar_color="$WHITE" | |
| elif [ "$percent" -lt 80 ]; then | |
| bar_color="$YELLOW" | |
| else | |
| bar_color="$RED" | |
| fi | |
| # Build the bar | |
| local bar="" | |
| for ((i=0; i<filled; i++)); do | |
| bar+="β" | |
| done | |
| for ((i=0; i<empty; i++)); do | |
| bar+="β" | |
| done | |
| printf "%s%s%s %d%%" "$bar_color" "$bar" "$RESET" "$percent" | |
| } | |
| # Extract values | |
| model=$(get_model_name) | |
| model_icon=$(get_model_icon) | |
| output_style=$(get_output_style) | |
| current_dir=$(get_current_dir) | |
| project_dir=$(get_project_dir) | |
| cost_display=$(get_cost) | |
| context_bar=$(build_context_bar) | |
| # Get project name and handle subdirectory display | |
| project=$(basename "$project_dir") | |
| if [ "$current_dir" != "$project_dir" ]; then | |
| subdir=$(basename "$current_dir") | |
| project="${project} (CWD: ${subdir}/)" | |
| fi | |
| # Get git branch | |
| git_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "no-git") | |
| # Build statusline (order: branch β context β model β cost β style) | |
| statusline="" | |
| statusline+="${GREEN}${git_branch}${RESET}" | |
| statusline+=" ${SEP} " | |
| statusline+="${context_bar}" | |
| statusline+=" ${SEP} " | |
| statusline+="${MAGENTA}${model}${RESET}" | |
| statusline+=" ${SEP} " | |
| statusline+="${ICON_COST} ${CYAN}${cost_display}${RESET}" | |
| statusline+=" ${SEP} " | |
| statusline+="${ICON_STYLE} ${DIM}${output_style}${RESET}" | |
| echo -e "$statusline" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment