Skip to content

Instantly share code, notes, and snippets.

@kenjikato
Last active April 28, 2026 09:29
Show Gist options
  • Select an option

  • Save kenjikato/d62a746f5106f215fbb0d69d14eacfff to your computer and use it in GitHub Desktop.

Select an option

Save kenjikato/d62a746f5106f215fbb0d69d14eacfff to your computer and use it in GitHub Desktop.
Claude Code Customized Status Line
#!/bin/bash
input=$(cat)
# See the Claude Code Docs for adding this into your settings.json here: https://code.claude.com/docs/en/statusline#manually-configure-a-status-line
# Customized by: Kenji Kato
MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
DURATION_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
# "// empty" produces no output when rate_limits is absent
FIVE_H=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
WEEK=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
IN_TOK=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
OUT_TOK=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
LINES_ADDED=$(echo "$input" | jq -r '.cost.total_lines_added // 0')
LINES_REMOVED=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')
EXCEEDS_200K=$(echo "$input" | jq -r 'if (.context_window.total_input_tokens // 0) > 200000 then "1" else "" end')
# ANSI color codes (from PS1: bold cyan for user@host, bold magenta for path)
BOLD_CYAN='\033[1;36m'; BOLD_MAGENTA='\033[1;35m'
CYAN='\033[36m'; GREEN='\033[32m'; YELLOW='\033[33m'; RED='\033[31m'; RESET='\033[0m'
# PS1-style prompt line: bold cyan user@host : bold magenta ~/path
printf "${BOLD_CYAN}$(whoami)@$(hostname -s)${RESET}:${BOLD_MAGENTA}${DIR}${RESET}\n"
# Pick bar color based on context usage
if [ "$PCT" -ge 75 ]; then BAR_COLOR="$RED"
elif [ "$PCT" -ge 50 ]; then BAR_COLOR="$YELLOW"
else BAR_COLOR="$GREEN"; fi
FILLED=$((PCT / 10)); EMPTY=$((10 - FILLED))
printf -v FILL "%${FILLED}s"; printf -v PAD "%${EMPTY}s"
BAR="${FILL// /█}${PAD// /░}"
MINS=$((DURATION_MS / 60000)); SECS=$(((DURATION_MS % 60000) / 1000))
BRANCH=""
DIFF_STATS=""
if git -C "$DIR" rev-parse --git-dir > /dev/null 2>&1; then
BRANCH=" | 🌿 $(git -C "$DIR" branch --show-current 2>/dev/null) | "
NUMSTAT=$(git -C "$DIR" diff --numstat 2>/dev/null)
ADDED=$(echo "$NUMSTAT" | awk '{sum += $1} END {print sum+0}')
REMOVED=$(echo "$NUMSTAT" | awk '{sum += $2} END {print sum+0}')
DIFF_STATS=" ${GREEN}+${ADDED}${RESET} / ${RED}-${REMOVED}${RESET}"
fi
printf "🧠 ${CYAN}[$MODEL]${RESET} | 📁 ${DIR##*/}${BRANCH}${DIFF_STATS}\n"
COST_FMT=$(printf '$%.2f' "$COST")
LIMITS=""
[ -n "$FIVE_H" ] && LIMITS="5h: $(printf '%.0f' "$FIVE_H")%"
[ -n "$WEEK" ] && LIMITS="${LIMITS:+$LIMITS }7d: $(printf '%.0f' "$WEEK")%"
IN_FMT=$(printf '%d' "$IN_TOK"); OUT_FMT=$(printf '%d' "$OUT_TOK")
WARN_200K=""
[ -n "$EXCEEDS_200K" ] && WARN_200K=" | ⚠️ 200K tokens exceeded for single input! Context was probably lost!"
echo -ne "⏳${BAR_COLOR}${BAR}${RESET} ${PCT}% | ➡️ ${CYAN}In:${RESET} ${IN_FMT} tokens | ⬅️ ${CYAN}Out:${RESET} ${OUT_FMT} tokens${WARN_200K}\n"
echo -ne "💸 ${YELLOW}${COST_FMT}${RESET} | ⏱️ ${MINS}m ${SECS}s | " && echo -ne "⏰ Limits - " && [ -n "$LIMITS" ] && echo -ne "$LIMITS\n" || echo -ne "?\n"
# printf "Lines Added: ${GREEN}${LINES_ADDED}${RESET} | Lines Removed: ${RED}${LINES_REMOVED}${RESET}\n"
@kenjikato
Copy link
Copy Markdown
Author

kenjikato commented Apr 26, 2026

This is a custom Claude Code Statusline that mixes elements from Anthropic's examples into a single statusline.sh bash script.

Claude_Comandline_Custom_2

To install this custom statusline.sh for Claude Code manually:

  1. Copy this gist, by downloading a zip of it in the upper right corner of the gists GitHub interface, or simply copy the above scripts text itself.
  2. Copy the downloaded statusline.sh (or past the copied text into) your system wide ~/.claude/statusline.sh
  3. Edit your ~/.claude/settings.json using any standard code editor.
  4. Add the following into the settings.json file:
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh",
    "padding": 2
  }
}

To have Claude do this for you:

  1. Paste the following into your Claude Code command line:
    Download the custome statusline.sh found at the following GitHub gits and use it as my Claude Code statusline. https://gist.github.com/kenjikato/d62a746f5106f215fbb0d69d14eacfff

For more information on creating custom Claude Code Statusline setups see Anthropic's documentation.
Customize your status line
https://code.claude.com/docs/en/statusline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment