Skip to content

Instantly share code, notes, and snippets.

@arazabishov
Forked from sverrejoh/gist-readme.md
Last active March 4, 2026 15:35
Show Gist options
  • Select an option

  • Save arazabishov/03dea7ae7c51a6bc6381547bad7aed9b to your computer and use it in GitHub Desktop.

Select an option

Save arazabishov/03dea7ae7c51a6bc6381547bad7aed9b to your computer and use it in GitHub Desktop.
Claude Code custom status line — git branch, context usage, model info

Claude Code Custom Status Line

A rich, colorful status line for Claude Code that shows model info, context usage, git branch, and more — right in your terminal.

Status line preview

What it shows

Section Example Description
Model Opus 4.6 (1M context) Active model display name
Context bar ⣿⣿⣿⣀⣀⣀⣀⣀ Braille progress bar with amber→orange→rust truecolor gradient
Usage 3% 34K/1000K Context window percentage and token counts
Branch main Current git branch (read from .git/HEAD — no subprocess)

Features

  • Truecolor gradient progress bar using braille characters (⣿ filled, ⣀ empty)
  • Git branch displayed — reads .git/HEAD directly for zero-overhead detection
  • Compact token display — shows 34K/1000K instead of raw numbers
  • Zero dependencies beyond bash and jq

Setup

  1. Save statusline.sh to ~/.claude/statusline.sh and make it executable: chmod +x ~/.claude/statusline.sh

  2. Add this to your ~/.claude/settings.json: { "statusLine": { "type": "command", "command": "bash -c '$HOME/.claude/statusline.sh'" } }

  3. Restart Claude Code — the status line appears at the bottom of the TUI.

How it works

Claude Code pipes a JSON blob to the status line command via stdin on every render. The script reads it with jq to extract:

  • context_window.context_window_size — max context tokens
  • context_window.current_usage — input, cache creation, and cache read tokens
  • model.display_name / model.id — active model
  • cwd — working directory (used for branch detection)

The git branch is detected by reading ${cwd}/.git/HEAD directly — a single file read with no subprocess overhead. The gradient is computed in pure bash arithmetic — no external color libraries needed.

Customization

  • Bar width: Change bar_width=8 to make the progress bar wider/narrower
  • Colors: Edit the r1,g1,b1 / r2,g2,b2 / r3,g3,b3 RGB values for a different gradient
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
input=$(cat)
# Extract data
context_limit=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')
cwd=$(echo "$input" | jq -r '.cwd // ""')
model_name=$(echo "$input" | jq -r '.model.display_name // .model.id // "unknown"')
# Use current_usage (current context)
usage=$(echo "$input" | jq '.context_window.current_usage')
if [ "$usage" != "null" ] && [ "$usage" != "" ]; then
total_used=$(echo "$usage" | jq '.input_tokens + .cache_creation_input_tokens +
.cache_read_input_tokens')
used_pct=$((total_used * 100 / context_limit))
else
total_used=0
used_pct=0
fi
# Colors
R="\033[0m"
B="\033[1m"
c() { printf "\033[38;5;%sm" "$1"; }
format_k() {
local n=$1
if [ $n -ge 1000 ]; then
echo "$((n/1000))K"
else
echo "$n"
fi
}
used_fmt=$(format_k $total_used)
limit_fmt=$(format_k $context_limit)
# Git branch (read .git/HEAD directly — no subprocess)
branch=""
head_file="${cwd}/.git/HEAD"
if [ -f "$head_file" ]; then
read -r head < "$head_file"
branch="${head#ref: refs/heads/}"
fi
branch="${branch:-?}"
# Braille progress bar - truecolor gradient O: Amber -> Orange -> Rust
bar_width=8
filled=$(( (used_pct * bar_width + 50) / 100 ))
# Gradient: (255,200,80) -> (230,130,30) -> (180,60,20)
r1=255; g1=200; b1=80
r2=230; g2=130; b2=30
r3=180; g3=60; b3=20
er=60; eg=60; eb=60
bar=""
for ((i=0; i<bar_width; i++)); do
if [ $i -lt $filled ]; then
if [ $filled -gt 1 ]; then
t=$((i * 200 / (filled - 1)))
else
t=0
fi
if [ $t -le 100 ]; then
r=$(( r1 + (r2 - r1) * t / 100 ))
g=$(( g1 + (g2 - g1) * t / 100 ))
b=$(( b1 + (b2 - b1) * t / 100 ))
else
t2=$((t - 100))
r=$(( r2 + (r3 - r2) * t2 / 100 ))
g=$(( g2 + (g3 - g2) * t2 / 100 ))
b=$(( b2 + (b3 - b2) * t2 / 100 ))
fi
bar+="\033[38;2;${r};${g};${b}m⣿${R}"
else
bar+="\033[38;2;${er};${eg};${eb}m⣀${R}"
fi
done
# Build status line
printf '%b' "$(c 156) ${model_name}${R} "
printf '%b' "${bar} "
printf '%b' "${B}${used_pct}%${R} ${used_fmt}/${limit_fmt} "
printf '%b\n' "$(c 139) ${branch}${R}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment