Skip to content

Instantly share code, notes, and snippets.

@nathanialhenniges
Last active February 19, 2026 04:29
Show Gist options
  • Select an option

  • Save nathanialhenniges/01f699aaab4609fbc69bf8c3458813c1 to your computer and use it in GitHub Desktop.

Select an option

Save nathanialhenniges/01f699aaab4609fbc69bf8c3458813c1 to your computer and use it in GitHub Desktop.
Claude Code Status Line - Rich 2-line status bar with emojis
#!/bin/bash
input=$(cat)
# Extract fields from JSON stdin
dir=$(echo "$input" | jq -r '.workspace.current_dir // ""')
model=$(echo "$input" | jq -r '.model.display_name // "Unknown"')
cost=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
ctx_pct=$(echo "$input" | jq -r '.context_window.used_percentage // 0')
input_tokens=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
output_tokens=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
# Format duration as MM:SS
duration_s=$(( duration_ms / 1000 ))
duration_min=$(( duration_s / 60 ))
duration_sec=$(( duration_s % 60 ))
duration_fmt=$(printf "%02d:%02d" "$duration_min" "$duration_sec")
# Format tokens as K
format_tokens() {
local t=$1
if [ "$t" -ge 1000 ]; then
awk "BEGIN { printf \"%.1fK\", $t / 1000 }"
else
echo "${t}"
fi
}
input_fmt=$(format_tokens "$input_tokens")
output_fmt=$(format_tokens "$output_tokens")
# --- Git info ---
org_repo=""
branch=""
if [ -n "$dir" ] && git -C "$dir" rev-parse --git-dir > /dev/null 2>&1; then
remote_url=$(git -C "$dir" --no-optional-locks config --get remote.origin.url 2>/dev/null)
if [ -n "$remote_url" ]; then
org_repo="$remote_url"
org_repo="${org_repo%.git}"
org_repo="${org_repo##*github.com/}"
org_repo="${org_repo##*github.com:}"
[ "$org_repo" = "$remote_url" ] && org_repo=""
fi
branch=$(git -C "$dir" --no-optional-locks branch --show-current 2>/dev/null)
fi
# --- Line 1: org/repo (branch) + working directory ---
line1="πŸ“‚ ${org_repo:-local}"
[ -n "$branch" ] && line1="${line1} (${branch})"
[ -n "$dir" ] && line1="${line1} | πŸ“ ${dir/#$HOME/~}"
# --- Line 2: model + context + duration + cost + tokens ---
cost_fmt=$(printf "\$%.2f" "$cost")
line2="πŸ€– ${model} Β· Ctx ${ctx_pct}% Β· ⏱ ${duration_fmt} | πŸ’² ${cost_fmt} Β· πŸ“Š ${input_fmt} in / ${output_fmt} out"
# Set terminal title
[ -n "$org_repo" ] && printf '\033]0;%s\007' "$org_repo"
echo "$line1"
echo "$line2"

Claude Code Status Line

A rich 2-line status bar for Claude Code that displays session info with emojis.

Preview

πŸ“‚ MrDemonWolf/official-app (dev) | πŸ“ ~/Developer/mrdemonwolf/official-app
πŸ€– Opus 4.6 Β· Ctx 25% Β· ⏱ 19:38 | πŸ’² $2.57 Β· πŸ“Š 18.7K in / 22.7K out

What's displayed

Line Info
Line 1 πŸ“‚ GitHub org/repo, branch
Line 2 πŸ€– Model name Β· Context % Β· ⏱ Duration

Requirements

  • jq
  • Git (for repo/branch detection)

Installing jq

macOS:

brew install jq

Ubuntu/WSL:

sudo apt update && sudo apt install -y jq

Setup

  1. Create the Claude config directory (if it doesn't exist):

    mkdir -p ~/.claude
  2. Download the script:

    curl -o ~/.claude/statusline-command.sh \
      https://gist.githubusercontent.com/nathanialhenniges/01f699aaab4609fbc69bf8c3458813c1/raw/statusline-command.sh
  3. Make it executable:

    chmod +x ~/.claude/statusline-command.sh
  4. Configure Claude Code to use it by adding to ~/.claude/settings.json:

    {
      "statusLine": {
        "command": "bash ~/.claude/statusline-command.sh"
      }
    }

    Or if you already have a settings.json, just add the statusLine key.

  5. Restart Claude Code to see the status line.

Customization

The script is plain bash β€” edit ~/.claude/statusline-command.sh to tweak the layout, change emojis, or add/remove fields. All data comes from JSON piped in by Claude Code on stdin.

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