Skip to content

Instantly share code, notes, and snippets.

@codewithmustafa
Last active February 8, 2026 16:08
Show Gist options
  • Select an option

  • Save codewithmustafa/0442233cf9ed0224b8cc1c31957f8cd0 to your computer and use it in GitHub Desktop.

Select an option

Save codewithmustafa/0442233cf9ed0224b8cc1c31957f8cd0 to your computer and use it in GitHub Desktop.
Custom Claude Code status line with motivational quotes, progress bar & token counter. Customize as you wish.
#!/bin/bash
# Claude Code Status Line Script
# Location: ~/.claude/statusline.sh
# Design: Opus 4.6 | Ship it! | [████████████████████████] 23% | 17.7K tokens
# Dependencies: jq
# macOS: brew install jq
# Ubuntu/Debian: sudo apt install jq
# Fedora: sudo dnf install jq
# Arch: sudo pacman -S jq
# Motivation quotes
quotes=(
"Ship it!"
"Build, break, learn."
"One commit at a time."
"Make it work, make it right."
"Keep pushing forward."
)
quote=${quotes[$((RANDOM % ${#quotes[@]}))]}
# Random decorators
decorators=("✦" "»" "⚡" "★")
deco=${decorators[$((RANDOM % ${#decorators[@]}))]}
# Read JSON input from stdin
input=$(cat)
# Extract model info
model=$(echo "$input" | jq -r '.model.display_name // .model.id // empty')
# Get percentage
used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty')
# Calculate total used tokens from current_usage
# Sum: input_tokens + output_tokens + cache_creation_input_tokens + cache_read_input_tokens
used_tokens=$(echo "$input" | jq -r '
.context_window.current_usage |
if . then
((.input_tokens // 0) + (.output_tokens // 0) + (.cache_creation_input_tokens // 0) + (.cache_read_input_tokens // 0))
else
0
end
')
# Shorten model name
if [ -n "$model" ]; then
short_model=$(echo "$model" | sed -E 's/Claude ([0-9.]+) (.*)/\2 \1/' | sed -E 's/claude-([a-z]+)-([0-9.-]+).*/\u\1 \2/')
else
short_model="Claude"
fi
# Format tokens (e.g., 17700 -> 17.7K)
format_tokens() {
local tokens=$1
if [ -z "$tokens" ] || [ "$tokens" = "null" ] || [ "$tokens" = "0" ]; then
echo "0"
return
fi
# Handle decimal numbers - extract integer part
tokens=$(echo "$tokens" | sed 's/\..*//')
# Ensure it's a number
if ! [[ "$tokens" =~ ^[0-9]+$ ]]; then
echo "0"
return
fi
if [ "$tokens" -ge 1000000 ]; then
local m=$(echo "scale=1; $tokens / 1000000" | bc)
echo "${m}M"
elif [ "$tokens" -ge 1000 ]; then
local k=$(echo "scale=1; $tokens / 1000" | bc)
echo "${k}K"
else
echo "$tokens"
fi
}
# Create progress bar
create_progress_bar() {
local pct=$1
local width=24
if [ -z "$pct" ] || [ "$pct" = "null" ]; then
pct=0
fi
pct=$(printf "%.0f" "$pct" 2>/dev/null || echo "0")
local filled=$((pct * width / 100))
local empty=$((width - filled))
[ "$filled" -lt 0 ] && filled=0
[ "$empty" -lt 0 ] && empty=0
local bar=""
for ((i=0; i<filled; i++)); do
bar+="█"
done
for ((i=0; i<empty; i++)); do
bar+=" "
done
echo "$bar"
}
# Get formatted values
tokens_formatted=$(format_tokens "$used_tokens")
progress_bar=$(create_progress_bar "$used_pct")
# Handle percentage for display
if [ -z "$used_pct" ] || [ "$used_pct" = "null" ]; then
used_pct=0
fi
display_pct=$(printf "%.0f" "$used_pct" 2>/dev/null || echo "0")
# Output the status line
echo "${short_model} | ${deco} ${quote} | [${progress_bar}] ${display_pct}% | ${tokens_formatted} tokens"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment