Skip to content

Instantly share code, notes, and snippets.

@mdoering
Created April 29, 2026 08:50
Show Gist options
  • Select an option

  • Save mdoering/67212299857be946420bae06c0116edd to your computer and use it in GitHub Desktop.

Select an option

Save mdoering/67212299857be946420bae06c0116edd to your computer and use it in GitHub Desktop.
Claude Statusline script
#!/bin/sh
input=$(cat)
GREEN='\033[32m'
YELLOW='\033[33m'
RED='\033[31m'
BLUE='\033[34m'
CYAN='\033[36m'
WHITE='\033[37m'
RESET='\033[0m'
BRAIN='\033[35m'
model=$(echo "$input" | jq -r '.model.display_name // "Unknown Model"')
used=$(echo "$input" | jq -r '.context_window.used_percentage // empty')
worktree=$(echo "$input" | jq -r '.worktree.name // empty')
total_cost=$(echo "$input" | jq -r '.cost.total_cost_usd // empty')
current_dir=$(echo "$input" | jq -r '.worktree.original_cwd // empty')
rl_5h_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty' | awk '{printf "%.0f", $1}')
rl_5h_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
rl_7d_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
rl_7d_reset=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty')
make_bar() {
pct="$1"
width=10
filled=$(( pct * width / 100 ))
empty=$(( width - filled ))
bar=""
i=0
while [ $i -lt $filled ]; do bar="${bar}█"; i=$(( i + 1 )); done
while [ $i -lt $width ]; do bar="${bar}░"; i=$(( i + 1 )); done
printf "%s" "$bar"
}
format_pct() {
pct="$1"
use_bar="$2"
trailing="$3"
[ -z "$pct" ] && return
if [ "$pct" -ge 90 ]; then color="$RED"
elif [ "$pct" -ge 70 ]; then color="$YELLOW"
else color="$GREEN"
fi
# Only build bar if requested
if [ "$use_bar" = "1" ] || [ "$use_bar" = "true" ]; then
bar=$(make_bar "$pct")
bar_str="${bar} "
else
bar_str=""
fi
printf "${color}${bar_str}${pct}%%${trailing}${RESET}"
}
model_str= printf "$YELLOW$model$RESET"
if [ -n "$used" ]; then
usage_str=$(printf "${BRAIN}󰧑 %.0f%%${RESET}" "$used")
else
usage_str="${BRAIN}󰧑 0%%${RESET}"
fi
if [ -n "$worktree" ]; then
worktree_str="󰐅 ${worktree}"
else
worktree_str="no worktree"
fi
git_str=""
if git rev-parse --git-dir > /dev/null 2>&1; then
branch=$(git branch --show-current 2>/dev/null)
[ -z "$branch" ] && branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
staged=$(git diff --cached --numstat 2>/dev/null | wc -l | tr -d ' ')
modified=$(git diff --numstat 2>/dev/null | wc -l | tr -d ' ')
git_str="$(printf "${CYAN}${branch}${RESET}")"
[ "$staged" -gt 0 ] && git_str="${git_str} $(printf "${GREEN}+${staged}${RESET}")"
[ "$modified" -gt 0 ] && git_str="${git_str} $(printf "${YELLOW}~${modified}${RESET}")"
else
git_str="$(printf "${CYAN}no branch${RESET}")"
fi
rate_limit_str=""
rate_limit_str="$(format_pct "$rl_5h_pct" "true" "")"
reset_time=$(date -r "$rl_5h_reset" "+%-I:%M%p" 2>/dev/null || date -d "@$rl_5h_reset" "+%-I:%M%p" 2>/dev/null)
week_limit_str="$(format_pct "$rl_7d_pct" "false" " Week")"
repo_root=$(cd "$current_dir" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null || echo "$current_dir")
dir_display=$(basename "$repo_root")
dir_colored=$(printf "${WHITE}${dir_display}${RESET}")
worktree_colored=$(printf "${BLUE}${worktree_str}${RESET}")
printf "%s | %s | %s resets %s - %s\n%s | %s |  %s" "$model_str" "$usage_str" "$rate_limit_str" "$reset_time" "$week_limit_str" "$dir_colored" "$worktree_colored" "$git_str"
@mdoering
Copy link
Copy Markdown
Author

Statusline Screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment