DEV Community

Varun D
Varun D

Posted on

[Claude Code] Super Simple Statusline

Official documentation

Super Simple Statusline for Claude Code

Tested on Mac

This Super Simple Statusline shows Model Name, input token count, output token count, context progress bar + % and git status if available.

1. Install jq command line tool

JQ makes json parsing easier

JQ installation

2. Enable statusline in Claude Code settings

Modify your settings.json file found in top level .claude folder ~/.claude/settings.json.
If the file doesn't exist, create it.

Enable statusline

 {
    "statusLine": {
      "type": "command",
      "command": "~/.claude/statusline.sh",
      "padding": 2
    }
  }
Enter fullscreen mode Exit fullscreen mode

3. Create statusline file and make it executable

Create statusline.sh file in the same folder

You can name it anything but make sure file path is the same in "command" in the settings.

touch ~/.claude/statusline.sh

Make it executable

chmod +x ~/.claude/statusline.sh

Write the statusline script to statusline.sh

This Super Simple Statusline file shows Model Name, input token count, output token count and context % progress bar.

#!/bin/bash
# Read JSON data that Claude Code sends to stdin
# Remember to install jq to extract data from json string, makes it easier
# You can piple json in text format to test the script
input=$(cat)

# Set color variables. Escape sequences can vary by system, bash, zsh, etc.
GREEN=$'\033[32m'
YELLOW=$'\033[33m'
RED=$'\033[91m'
RESET=$'\033[0m'

# Extract fields using jq. Remember to install jq
# Get Model Name
MODEL=$(echo "$input" | jq -r '.model.display_name')
# Get Used Percentage, Total Outout Tokens and Total Input Tokens, save to variables
# The "// 0" provides a fallback if the field is null
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
OTOK=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0' | cut -d. -f1)
ITOK=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0' | cut -d. -f1)

# Context progress bar, yey
BAR_WIDTH=10
FILLED=$((PCT * BAR_WIDTH / 100))
EMPTY=$((BAR_WIDTH - FILLED))
BAR=""
[ "$FILLED" -gt 0 ] && BAR=$(printf "%${FILLED}s" | tr ' ' '▓')
[ "$EMPTY" -gt 0 ] && BAR="${BAR}$(printf "%${EMPTY}s" | tr ' ' '░')"

# Pick bar color based on usage. < 50 green, < 80 yello, otherwise red
if [ "$PCT" -lt 50 ]; then
    BAR_COLOR="$GREEN"
elif [ "$PCT" -lt 80 ]; then
    BAR_COLOR="$YELLOW"
else
    BAR_COLOR="$RED"  # bright red
fi

# Git status for folder, if available
if git rev-parse --git-dir > /dev/null 2>&1; then
    BRANCH=$(git branch --show-current 2>/dev/null)
    STAGED=$(git diff --cached --numstat 2>/dev/null | wc -l | tr -d ' ')
    MODIFIED=$(git diff --numstat 2>/dev/null | wc -l | tr -d ' ')

    GIT_STATUS=""
    [ "$STAGED" -gt 0 ] && GIT_STATUS="${GREEN}+${STAGED}${RESET}"
    [ "$MODIFIED" -gt 0 ] && GIT_STATUS="${GIT_STATUS}${YELLOW}~${MODIFIED}${RESET}"

    # Show statusline with git status if available
    echo -e "$MODEL | i$ITOK, o$OTOK | cntxt ${BAR_COLOR}$BAR${RESET} ${PCT}% |⎇  $BRANCH $GIT_STATUS"
else
    # Else show statusline without git status
    echo -e "$MODEL | i$ITOK, o$OTOK | cntxt ${BAR_COLOR}$BAR${RESET} ${PCT}%"
fi
Enter fullscreen mode Exit fullscreen mode

3. Troubleshooting

a. If statusline isn't loading, check folder structure
b. Make sure statusline.sh file is executable, chmod +x ~/.claude/statusline.sh
c. Bash scripting is flaky, check quotes and escape characters

Top comments (2)

Collapse
 
slima4 profile image
Slim

Nice approach! I started with a statusline too, then kept adding stuff: cost tracking, context sparkline, compaction prediction, a live monitor dashboard for a second terminal, session analytics, and hooks for file activity warnings.

Collapse
 
disdar profile image
Disdar

Genuinely useful addition for Claude Code power users. Keeping model name, token counts, and context usage visible at a glance removes the "am I about to hit the limit?" anxiety during long sessions — and the color-coded progress bar gives you a visual warning before context suddenly truncates on you.

The git integration is the standout part: staged vs. modified file counts right in the statusline without switching panes. The jq dependency is a reasonable tradeoff — pure bash JSON parsing gets ugly fast, and the // 0 null fallbacks are good defensive practice for sessions where token data hasn't populated yet.

For developers running multiple Claude Code sessions across projects, Remocode pairs naturally with this kind of setup — split-pane terminal overview of all your agents with Telegram-based remote control, so you're not babysitting each window separately.
One gotcha: if colors render incorrectly, the bash vs. zsh escape sequence difference is almost always the culprit. Verify your #!/bin/bash shebang and shell environment first.