Powerline Status Line for Claude CLI A developer created a Powerlevel10k-style status line for Claude CLI, displaying session name, current directory, git branch status, Vim mode, model name, context window usage, and rate limit information in a single line. The bash script parses JSON input from Claude Code to populate color-coded segments with pill-shaped badges and separators. The status line includes visual indicators for dirty git repositories, remaining context capacity, and API rate limit consumption. | /bin/bash | | | Claude Code statusLine — sexy Powerlevel10k-style | | | Segments: session • cwd • git • vim • model • context bar • rate limits • caveman | | | input=$ cat | | | ── Palette ──────────────────────────────────────────────────────────────── | | | RESET=$'\033 0m' | | | BOLD=$'\033 1m' | | | DIM=$'\033 2m' | | | Foreground | | | FG WHITE=$'\033 97m' | | | FG BLACK=$'\033 30m' | | | FG BLUE=$'\033 34m' | | | FG CYAN=$'\033 36m' | | | FG GREEN=$'\033 32m' | | | FG YELLOW=$'\033 33m' | | | FG RED=$'\033 31m' | | | FG MAGENTA=$'\033 35m' | | | FG ORANGE=$'\033 38;5;214m' | | | FG GRAY=$'\033 90m' | | | Background accents used for mini-badge style | | | BG BLUE=$'\033 44m' | | | BG CYAN=$'\033 46m' | | | BG GREEN=$'\033 42m' | | | BG YELLOW=$'\033 43m' | | | BG RED=$'\033 41m' | | | BG MAGENTA=$'\033 45m' | | | BG DARK=$'\033 48;5;236m' | | | BG ORANGE=$'\033 48;5;130m' | | | ── Helpers ──────────────────────────────────────────────────────────────── | | | SEP="${FG GRAY}│${RESET}" | | | Print a colored pill: bg fg text | | | pill { | | | local bg="$1" fg="$2" text="$3" | | | printf "${bg}${fg}${BOLD} %s ${RESET}" "$text" | | | } | | | Print a dim label + colored value | | | kv { | | | local label="$1" color="$2" value="$3" | | | printf "${FG GRAY}%s${RESET}${color}%s${RESET}" "$label" "$value" | | | } | | | ── Parse JSON once ──────────────────────────────────────────────────────── | | | cwd=$ echo "$input" | jq -r '.workspace.current dir // .cwd // empty' | | | model=$ echo "$input" | jq -r '.model.display name // empty' | | | session=$ echo "$input" | jq -r '.session name // empty' | | | remaining=$ echo "$input" | jq -r '.context window.remaining percentage // empty' | | | vim mode=$ echo "$input" | jq -r '.vim.mode // empty' | | | five pct=$ echo "$input" | jq -r '.rate limits.five hour.used percentage // empty' | | | week pct=$ echo "$input" | jq -r '.rate limits.seven day.used percentage // empty' | | | ── Segment: Session name ────────────────────────────────────────────────── | | | if -n "$session" ; then | | | pill "$BG DARK" "$FG CYAN" "✦ $session" | | | printf ' ' | | | fi | | | ── Segment: Directory ──────────────────────────────────────────────────── | | | if -n "$cwd" ; then | | | Show last 2 path components for context | | | dir display=$ echo "$cwd" | awk -F'/' '{ | | | n=NF | | | if n =2 printf "%s/%s", $ n-1 , $n | | | else print $n | | | }' | | | Replace $HOME with ~ | | | dir display=$ echo "$dir display" | sed "s|^$HOME|~|" | | | pill $'\033 48;5;24m' "$FG WHITE" " $dir display" | | | fi | | | ── Segment: Git ────────────────────────────────────────────────────────── | | | if -n "$cwd" ; then | | | git root=$ GIT OPTIONAL LOCKS=0 git -C "$cwd" rev-parse --show-toplevel 2 /dev/null | | | if -n "$git root" ; then | | | branch=$ GIT OPTIONAL LOCKS=0 git -C "$cwd" symbolic-ref --short HEAD 2 /dev/null \ | | | || GIT OPTIONAL LOCKS=0 git -C "$cwd" rev-parse --short HEAD 2 /dev/null | | | if -n "$branch" ; then | | | Check for dirty state fast, no locks | | | if GIT OPTIONAL LOCKS=0 git -C "$cwd" diff --quiet 2 /dev/null \ | | | && GIT OPTIONAL LOCKS=0 git -C "$cwd" diff --cached --quiet 2 /dev/null; then | | | pill $'\033 48;5;28m' "$FG WHITE" " $branch" | | | else | | | pill $'\033 48;5;136m' "$FG BLACK" " $branch " | | | fi | | | fi | | | fi | | | fi | | | ── Segment: Vim mode ───────────────────────────────────────────────────── | | | if -n "$vim mode" ; then | | | printf ' ' | | | case "$vim mode" in | | | NORMAL pill "$BG MAGENTA" "$FG WHITE" "N" ;; | | | INSERT pill "$BG CYAN" "$FG BLACK" "I" ;; | | | pill "$BG DARK" "$FG GRAY" "$vim mode" ;; | | | esac | | | fi | | | ── Separator ───────────────────────────────────────────────────────────── | | | printf ' %s ' "$SEP" | | | ── Segment: Model ──────────────────────────────────────────────────────── | | | if -n "$model" ; then | | | Shorten: "Claude 3.5 Sonnet" → "3.5 Sonnet" | | | short model=$ echo "$model" | sed 's/^Claude //' | | | printf "${FG MAGENTA}${BOLD}⬡ %s${RESET}" "$short model" | | | fi | | | ── Segment: Context bar ────────────────────────────────────────────────── | | | if -n "$remaining" ; then | | | remaining int=$ printf '%.0f' "$remaining" | | | used int=$ 100 - remaining int | | | Color based on remaining | | | if "$remaining int" -le 10 ; then ctx color="$FG RED"; ctx bg="$BG RED" | | | elif "$remaining int" -le 25 ; then ctx color="$FG ORANGE"; ctx bg="$BG ORANGE" | | | elif "$remaining int" -le 50 ; then ctx color="$FG YELLOW"; ctx bg="$BG YELLOW" | | | else ctx color="$FG GREEN"; ctx bg="$BG GREEN" | | | fi | | | 5-char mini progress bar ▓▓▓░░ | | | filled=$ used int 5 / 100 | | | empty=$ 5 - filled | | | bar="" | | | for i in $ seq 1 $filled ; do bar="${bar}▓"; done | | | for i in $ seq 1 $empty ; do bar="${bar}░"; done | | | printf ' %s ' "$SEP" | | | printf "${FG GRAY}ctx ${RESET}${ctx color}${bar} %d%%${RESET}" "$remaining int" | | | fi | | | ── Segment: Rate limits ────────────────────────────────────────────────── | | | if -n "$five pct" || -n "$week pct" ; then | | | printf ' %s ' "$SEP" | | | first=1 | | | if -n "$five pct" ; then | | | pct int=$ printf '%.0f' "$five pct" | | | if "$pct int" -ge 90 ; then rl color="$FG RED" | | | elif "$pct int" -ge 70 ; then rl color="$FG YELLOW" | | | else rl color="$FG GREEN" | | | fi | | | printf "${FG GRAY}5h${RESET} ${rl color}%d%%${RESET}" "$pct int" | | | first=0 | | | fi | | | if -n "$week pct" ; then | | | "$first" -eq 0 && printf "${FG GRAY} · ${RESET}" | | | pct int=$ printf '%.0f' "$week pct" | | | if "$pct int" -ge 90 ; then rl color="$FG RED" | | | elif "$pct int" -ge 70 ; then rl color="$FG YELLOW" | | | else rl color="$FG GREEN" | | | fi | | | printf "${FG GRAY}7d${RESET} ${rl color}%d%%${RESET}" "$pct int" | | | fi | | | fi | | | ── Segment: Caveman badge ──────────────────────────────────────────────── | | | FLAG="${CLAUDE CONFIG DIR:-$HOME/.claude}/.caveman-active" | | | if -f "$FLAG" && -L "$FLAG" ; then | | | MODE=$ head -c 64 "$FLAG" 2 /dev/null | tr -d '\n\r' | tr ' :upper: ' ' :lower: ' | | | MODE=$ printf '%s' "$MODE" | tr -cd 'a-z0-9-' | | | case "$MODE" in | | | off|lite|full|ultra|wenyan-lite|wenyan|wenyan-full|wenyan-ultra|commit|review|compress | | | printf ' %s ' "$SEP" | | | if -z "$MODE" || "$MODE" = "full" ; then | | | pill "$BG ORANGE" "$FG WHITE" "🪨 CAVEMAN" | | | else | | | SUFFIX=$ printf '%s' "$MODE" | tr ' :lower: ' ' :upper: ' | | | pill "$BG ORANGE" "$FG WHITE" "🪨 $SUFFIX" | | | fi | | | SAVINGS FILE="${CLAUDE CONFIG DIR:-$HOME/.claude}/.caveman-statusline-suffix" | | | if "${CAVEMAN STATUSLINE SAVINGS:-1}" = "0" && -f "$SAVINGS FILE" && -L "$SAVINGS FILE" ; then | | | SAVINGS=$ head -c 64 "$SAVINGS FILE" 2 /dev/null | tr -d '\000-\037' | | | -n "$SAVINGS" && printf " ${FG ORANGE}${SAVINGS}${RESET}" | | | fi | | | ;; | | | esac | | | fi |