Last active
March 4, 2026 11:15
-
-
Save RobinDev/2fe644971041502c938c76f43a67b141 to your computer and use it in GitHub Desktop.
Claude Code Status Line with current folder, model, cost ($) and %
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 | |
| # Claude Code status line script | |
| # Displays: repo name (or directory) + model + context usage + cost | |
| input=$(cat) | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty') | |
| used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| model=$(echo "$input" | jq -r '.model.display_name // empty') | |
| cost=$(echo "$input" | jq -r '.cost.total_cost_usd // empty') | |
| # Determine display name: git repo name if in a repo, otherwise basename of cwd | |
| if [ -n "$cwd" ] && git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then | |
| repo_name=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null | xargs basename) | |
| location="$repo_name" | |
| else | |
| location=$(basename "$cwd") | |
| fi | |
| # ANSI color codes | |
| GREEN=$'\033[32m' | |
| YELLOW=$'\033[33m' | |
| RED=$'\033[31m' | |
| CYAN=$'\033[36m' | |
| DIM=$'\033[2m' | |
| RESET=$'\033[0m' | |
| # Build output | |
| if [ -n "$used_pct" ]; then | |
| pct_int=${used_pct%.*} | |
| pct_int=${pct_int:-0} | |
| if [ "$pct_int" -lt 40 ]; then | |
| color="$GREEN" | |
| elif [ "$pct_int" -le 60 ]; then | |
| color="$YELLOW" | |
| else | |
| color="$RED" | |
| fi | |
| # Model segment | |
| model_str="" | |
| if [ -n "$model" ]; then | |
| model_str=" ${DIM}|${RESET} ${CYAN}${model}${RESET}" | |
| fi | |
| # Cost segment | |
| cost_str="" | |
| if [ -n "$cost" ] && [ "$cost" != "null" ]; then | |
| cost_fmt=$(LC_NUMERIC=C printf "%.4f" "$cost") | |
| cost_str=" ${DIM}|${RESET} \$${cost_fmt}" | |
| fi | |
| printf "%s%s%s ${DIM}|${RESET} ${color}%s%%%s" \ | |
| "$location" "$model_str" "$cost_str" "$pct_int" "$RESET" | |
| else | |
| printf "%s" "$location" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment