Created
April 26, 2026 21:09
-
-
Save KerryJones/783a6018289e417c8b3b29cd5e7c709e to your computer and use it in GitHub Desktop.
Claude Status Line
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
| #!/bin/bash | |
| # Read JSON input from stdin | |
| input=$(cat) | |
| # Extract values | |
| model=$(echo "$input" | jq -r '.model.display_name // .model.id // "Claude"') | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // ""') | |
| used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| vim_mode=$(echo "$input" | jq -r '.vim.mode // empty') | |
| plan_mode=$(echo "$input" | jq -r '.session.plan_mode // .plan_mode // empty') | |
| # Get git info (repo name + branch) — works from any subdirectory and in worktrees | |
| git_branch="" | |
| dir_name="~" | |
| if [ -n "$cwd" ]; then | |
| repo_root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null) | |
| if [ -n "$repo_root" ]; then | |
| dir_name=$(basename "$repo_root") | |
| branch=$(git -C "$cwd" rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| if [ -n "$branch" ] && [ "$branch" != "HEAD" ]; then | |
| git_branch=" ($branch)" | |
| fi | |
| else | |
| dir_name=$(basename "$cwd") | |
| fi | |
| fi | |
| # Color codes | |
| GREEN="\033[32m" | |
| YELLOW="\033[33m" | |
| RED="\033[31m" | |
| BLUE="\033[34m" | |
| MAGENTA="\033[35m" | |
| CYAN="\033[36m" | |
| RESET="\033[0m" | |
| # Model indicator (shorten common names) | |
| model_indicator="" | |
| if [ -n "$model" ] && [ "$model" != "null" ]; then | |
| # Shorten model names for display | |
| case "$model" in | |
| *"opus"*|*"Opus"*) model_short="Opus" ;; | |
| *"sonnet"*|*"Sonnet"*) model_short="Sonnet" ;; | |
| *"haiku"*|*"Haiku"*) model_short="Haiku" ;; | |
| *) model_short="$model" ;; | |
| esac | |
| model_indicator="${MAGENTA}${model_short}${RESET} " | |
| fi | |
| # Plan mode indicator | |
| plan_indicator="" | |
| if [ "$plan_mode" = "true" ] || [ "$plan_mode" = "1" ]; then | |
| plan_indicator="${CYAN}[PLAN]${RESET} " | |
| fi | |
| # Build context usage indicator with color-coded thresholds | |
| context_indicator="" | |
| if [ -n "$used_pct" ]; then | |
| used_int=$(printf "%.0f" "$used_pct") | |
| # Color thresholds: Green 0-40%, Yellow 40-70%, Red 70%+ | |
| if [ "$used_int" -lt 40 ]; then | |
| context_color=$GREEN | |
| elif [ "$used_int" -lt 70 ]; then | |
| context_color=$YELLOW | |
| else | |
| context_color=$RED | |
| fi | |
| context_indicator=" ${context_color}[${used_int}%]${RESET}" | |
| fi | |
| # Build vim mode indicator | |
| vim_indicator="" | |
| if [ -n "$vim_mode" ]; then | |
| if [ "$vim_mode" = "INSERT" ]; then | |
| vim_indicator=" ${GREEN}INSERT${RESET}" | |
| else | |
| vim_indicator=" ${BLUE}NORMAL${RESET}" | |
| fi | |
| fi | |
| # Output the status line | |
| echo -e "${model_indicator}${plan_indicator}${BLUE}${dir_name}${RESET}${git_branch}${context_indicator}${vim_indicator}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment