Skip to content

Instantly share code, notes, and snippets.

@yagop
Last active June 12, 2026 22:52
Show Gist options
  • Select an option

  • Save yagop/b6a19c4186ada5979ba931d2ce16392b to your computer and use it in GitHub Desktop.

Select an option

Save yagop/b6a19c4186ada5979ba931d2ce16392b to your computer and use it in GitHub Desktop.
Claude fancy statusline

Claude fancy statusline

A custom status line for Claude Code. It renders a compact, colorized line with your host, the active model, effort level, context-window usage, 5-hour and weekly token usage, and the current git branch with ahead/behind counts. All text is rendered in bold.

Example output:

πŸ’» root@71fc4b745d65  🐴 Opus 4.8  βš™οΈ xhigh effort  πŸͺŸ context window 4%  πŸ•” 5h token 18%  πŸ“… weekly tokens 42%  🌿 feat/typescript +1

What each segment means

Segment Source Notes
πŸ’» user@host whoami / $HOSTNAME user in red, host in blue
🐴 model .model.display_name -
βš™οΈ effort .effort.level -
πŸͺŸ context window N% .context_window.used_percentage turns red at >= 75%
πŸ•” 5h token N% .rate_limits.five_hour.used_percentage turns red at >= 75%
πŸ“… weekly tokens N% .rate_limits.seven_day.used_percentage turns red at >= 75%
🌿 branch +A -B git in .cwd branch name: green when ahead, red when behind, yellow when diverged; +A ahead (green), -B behind (red)

Every segment is bold. Segments are only shown when their data is present, so the line stays short early in a session and grows as more context is available. The πŸ•” and πŸ“… rate-limit segments only appear for Claude.ai Pro/Max subscribers, after the first API response in a session.

Requirements

  • bash
  • jq - parses the JSON Claude Code sends on stdin
  • git - only needed for the branch segment

Install

  1. Save the script to your Claude config directory and make it executable:

    curl -L https://gist.githubusercontent.com/yagop/b6a19c4186ada5979ba931d2ce16392b/raw/statusline-command.sh \
      -o ~/.claude/statusline-command.sh
    chmod +x ~/.claude/statusline-command.sh
  2. Point Claude Code at it in ~/.claude/settings.json:

    {
      "statusLine": {
        "type": "command",
        "command": "~/.claude/statusline-command.sh"
      }
    }
  3. Start (or restart) Claude Code. The status line appears at the bottom of the prompt.

How it works

Claude Code invokes the command on each render and pipes a JSON snapshot of the session to it on stdin. The script reads that JSON in a single jq pass, pulls out the fields above, and printfs one line of ANSI-colored text to stdout. Whatever the script prints becomes the status line.

For the branch segment, the script refreshes the remote with git fetch at most once a minute, detached in the background, so the ahead/behind counts stay current without ever blocking a render on the network. If jq is not installed it degrades to just user@host instead of failing.

To customize it, edit ~/.claude/statusline-command.sh directly - tweak the emojis, colors, thresholds, or drop segments you do not want.

#!/usr/bin/env bash
# Claude Code status line script
input=$(cat)
# Color palette (bold). Each component gets its own color. Use 24-bit
# truecolor when the terminal advertises it ($COLORTERM), otherwise fall back
# to the nearest basic 16-color codes so the line still renders everywhere.
RESET='\033[0m'
BOLD='\033[1m'
case "$COLORTERM" in
truecolor|24bit)
CORAL='\033[1;38;2;224;108;117m' # user, branch behind, -N
BLUE='\033[1;38;2;97;175;239m' # host
ORANGE='\033[1;38;2;215;119;87m' # model
PURPLE='\033[1;38;2;198;120;221m' # 5h tokens (normal)
CYAN='\033[1;38;2;86;182;194m' # context window (normal)
GREEN='\033[1;38;2;152;195;121m' # effort, branch ahead, +N
GOLD='\033[1;38;2;229;192;123m' # weekly tokens (normal), branch diverged
ALERT='\033[1;38;2;255;95;95m' # any meter >= 75%
;;
*)
CORAL='\033[1;31m' # user, branch behind, -N (red)
BLUE='\033[1;34m' # host (blue)
ORANGE='\033[1;33m' # model (yellow)
PURPLE='\033[1;35m' # 5h tokens (normal) (magenta)
CYAN='\033[1;36m' # context window (normal) (cyan)
GREEN='\033[1;32m' # effort, branch ahead, +N (green)
GOLD='\033[1;93m' # weekly tokens (normal) (bright yellow)
ALERT='\033[1;91m' # any meter >= 75% (bright red)
;;
esac
# --- dependency guard: without jq we can't read the payload ---
if ! command -v jq >/dev/null 2>&1; then
host="${HOSTNAME%%.*}"
printf 'πŸ’» %s@%s (jq not found)\n' "$(whoami)" "${host:-$(hostname 2>/dev/null)}"
exit 0
fi
# --- parse every field in a single jq pass ---
# Fields use // "" (not // empty) so each is always exactly one line,
# keeping the positional reads below aligned.
{
IFS= read -r model
IFS= read -r effort
IFS= read -r used_pct
IFS= read -r five_pct
IFS= read -r week_pct
IFS= read -r cwd
} < <(printf '%s' "$input" | jq -r '
(.model.display_name // ""),
(.effort.level // ""),
(.context_window.used_percentage // "" | tostring),
(.rate_limits.five_hour.used_percentage // "" | tostring),
(.rate_limits.seven_day.used_percentage // "" | tostring),
(.cwd // .workspace.current_dir // "")
')
# --- user@host ---
user=$(whoami)
host="${HOSTNAME%%.*}"
[ -n "$host" ] || host=$(hostname 2>/dev/null)
printf "πŸ’» ${CORAL}%s${RESET}${BOLD}@${RESET}${BLUE}%s${RESET}" "$user" "$host"
# --- model ---
if [ -n "$model" ]; then
printf " 🐴 ${ORANGE}%s${RESET}" "$model"
fi
# --- effort ---
if [ -n "$effort" ]; then
printf " βš™οΈ ${GREEN}%s effort${RESET}" "$effort"
fi
# --- context window ---
if [ -n "$used_pct" ]; then
used_int=$(printf '%.0f' "$used_pct")
if [ "$used_int" -ge 75 ]; then
printf " πŸͺŸ ${ALERT}context window %s%%${RESET}" "$used_int"
else
printf " πŸͺŸ ${CYAN}context window %s%%${RESET}" "$used_int"
fi
fi
# --- 5h tokens (5-hour rate limit) ---
if [ -n "$five_pct" ]; then
five_int=$(printf '%.0f' "$five_pct")
if [ "$five_int" -ge 75 ]; then
printf " πŸ•” ${ALERT}5h token %s%%${RESET}" "$five_int"
else
printf " πŸ•” ${PURPLE}5h token %s%%${RESET}" "$five_int"
fi
fi
# --- weekly tokens (7-day rate limit) ---
if [ -n "$week_pct" ]; then
week_int=$(printf '%.0f' "$week_pct")
cal_emoji="πŸ“…"
if [ "$week_int" -ge 75 ]; then
printf " %s ${ALERT}weekly tokens %s%%${RESET}" "$cal_emoji" "$week_int"
else
printf " %s ${GOLD}weekly tokens %s%%${RESET}" "$cal_emoji" "$week_int"
fi
fi
# --- git branch with ahead/behind counts ---
if [ -n "$cwd" ] && [ -d "$cwd" ]; then
branch=$(git -C "$cwd" rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -n "$branch" ] && [ "$branch" != "HEAD" ]; then
# Refresh the remote at most once a minute, detached in the background,
# so the status line never blocks on the network. The ahead/behind read
# below uses whatever the last fetch left in the local refs.
stamp="${TMPDIR:-/tmp}/.sl_fetch_$(printf '%s' "$cwd" | tr -c 'A-Za-z0-9' '_')"
if [ ! -f "$stamp" ] || [ -n "$(find "$stamp" -mmin +1 2>/dev/null)" ]; then
touch "$stamp"
( git -C "$cwd" fetch --no-auto-gc --no-tags -q >/dev/null 2>&1 & ) >/dev/null 2>&1
fi
remote=$(git -C "$cwd" rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>/dev/null)
if [ -n "$remote" ]; then
ahead=$(git -C "$cwd" rev-list --count "${remote}..HEAD" 2>/dev/null || echo 0)
behind=$(git -C "$cwd" rev-list --count "HEAD..${remote}" 2>/dev/null || echo 0)
else
ahead=0
behind=0
fi
suffix=""
if [ "$ahead" -gt 0 ]; then
suffix="${suffix}${GREEN} +${ahead}${RESET}"
fi
if [ "$behind" -gt 0 ]; then
suffix="${suffix}${CORAL} -${behind}${RESET}"
fi
# Branch name color: green if ahead, coral if behind, gold if diverged.
if [ "$ahead" -gt 0 ] && [ "$behind" -gt 0 ]; then
branch_color="$GOLD"
elif [ "$ahead" -gt 0 ]; then
branch_color="$GREEN"
elif [ "$behind" -gt 0 ]; then
branch_color="$CORAL"
else
branch_color="$BOLD"
fi
printf " 🌿 ${branch_color}%s${RESET}%b" "$branch" "$suffix"
fi
fi
printf '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment