claude-code-tips

Claude Code Scripts

context-bar.sh

A two-line status line script for Claude Code that shows model, directory, git branch, uncommitted file count, sync status with origin, context usage, and your last message.

Example output:

Opus 4.5 | 📁claude-code-tips | 🔀main (scripts/context-bar.sh uncommitted, synced 12m ago) | ██░░░░░░░░ 18% of 200k tokens
💬 This is good. I don't think we need to change the documentation as long as we don't say that the default color is orange el...

Installation

  1. Copy the script to your Claude scripts directory:
    mkdir -p ~/.claude/scripts
    cp context-bar.sh ~/.claude/scripts/
    chmod +x ~/.claude/scripts/context-bar.sh
    
  2. Update your ~/.claude/settings.json:
    {
      "statusLine": {
        "type": "command",
        "command": "~/.claude/scripts/context-bar.sh"
      }
    }
    

That’s it!

Color Themes

The script supports optional color themes for the model name and progress bar. Edit the COLOR variable at the top of the script:

# Color theme: gray, orange, blue, teal, green, lavender, rose, gold, slate, cyan
COLOR="orange"

Preview all options by running bash scripts/color-preview.sh:

Color preview options

Requirements

How it works

Claude Code passes session metadata to status line commands via stdin as JSON, including:

The script uses these JSON fields to calculate context usage (input + output tokens), showing percentage of the context window. Use /context for precise token breakdown.