Created
August 1, 2026 06:09
-
-
Save derekkwok/09f9b1f1f6ec6395e680ff2f38348ab1 to your computer and use it in GitHub Desktop.
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 | |
| # Claude Code statusline: model name, git branch, context usage progress bar, 5-hour rate limit usage. | |
| input=$(cat) | |
| model=$(echo "$input" | jq -r '.model.display_name // "unknown"') | |
| dir=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty') | |
| used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| in_tok=$(echo "$input" | jq -r '.context_window.total_input_tokens // empty') | |
| out_tok=$(echo "$input" | jq -r '.context_window.total_output_tokens // empty') | |
| window_size=$(echo "$input" | jq -r '.context_window.context_window_size // empty') | |
| five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty') | |
| five_reset=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty') | |
| seven_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') | |
| seven_reset=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty') | |
| # Bright ANSI colors | |
| DIM='\033[2m' | |
| RESET='\033[0m' | |
| CYAN='\033[1;96m' | |
| YELLOW='\033[1;93m' | |
| MAGENTA='\033[1;95m' | |
| BLUE='\033[1;94m' | |
| GREEN='\033[1;92m' | |
| RED='\033[1;91m' | |
| parts=() | |
| parts+=("$(printf "${CYAN}%s${RESET}" "$model")") | |
| if [ -n "$dir" ]; then | |
| parts+=("$(printf "${GREEN}%s${RESET}" "$(basename "$dir")")") | |
| fi | |
| branch=$(git -C "${dir:-.}" rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| if [ -n "$branch" ]; then | |
| parts+=("$(printf "${RED}%s${RESET}" "$branch")") | |
| fi | |
| if [ -n "$in_tok" ] && [ -n "$out_tok" ] && [ -n "$window_size" ]; then | |
| tokens=$(printf "in:%sk out:%sk max:%sk" "$((in_tok / 1000))" "$((out_tok / 1000))" "$((window_size / 1000))") | |
| if [ -n "$used_pct" ]; then | |
| tokens=$(printf "%s %.0f%%" "$tokens" "$used_pct") | |
| fi | |
| parts+=("$(printf "${YELLOW}%s${RESET}" "$tokens")") | |
| fi | |
| if [ -n "$five_pct" ]; then | |
| five_str=$(printf "5h:%.0f%%" "$five_pct") | |
| if [ -n "$five_reset" ]; then | |
| reset_time=$(date -r "$five_reset" "+%l:%M%p" 2>/dev/null | sed 's/^ //; s/AM$/am/; s/PM$/pm/') | |
| if [ -n "$reset_time" ]; then | |
| five_str="$five_str (resets $reset_time)" | |
| fi | |
| fi | |
| parts+=("$(printf "${MAGENTA}%s${RESET}" "$five_str")") | |
| fi | |
| if [ -n "$seven_pct" ]; then | |
| seven_str=$(printf "7d:%.0f%%" "$seven_pct") | |
| if [ -n "$seven_reset" ]; then | |
| reset_time=$(date -r "$seven_reset" "+%a %l:%M%p" 2>/dev/null | sed 's/ */ /g; s/AM$/am/; s/PM$/pm/') | |
| if [ -n "$reset_time" ]; then | |
| seven_str="$seven_str (resets $reset_time)" | |
| fi | |
| fi | |
| parts+=("$(printf "${BLUE}%s${RESET}" "$seven_str")") | |
| fi | |
| out="" | |
| for p in "${parts[@]}"; do | |
| if [ -z "$out" ]; then | |
| out="$p" | |
| else | |
| out="$out ${DIM}|${RESET} $p" | |
| fi | |
| done | |
| printf "%b\n" "$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment