Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 2.52 KB

File metadata and controls

74 lines (55 loc) · 2.52 KB

Claude Code statusline — setup instructions

Instructions for Claude Code to execute. Follow in order.

1. Prerequisites

  • Platform: macOS or Linux. If Windows (non-WSL), stop.
  • jq installed (command -v jq). If missing, ask the user before installing via package manager.
  • git installed.

2. Back up and reset existing config

If ~/.claude/settings.json exists, copy it to ~/.claude/settings.json.bak.$(date +%Y%m%d-%H%M%S) before touching anything. Tell the user the backup path. If it doesn't exist, create it as {}.

Then, in the working copy:

  • If statusLine exists, remove it — clean replace, do not merge.
  • In hooks.UserPromptSubmit, remove any prior entry whose command writes to last-user-input- (old version of this hook). Leave unrelated hooks alone.
  • Preserve all other keys.

3. Install the script

mkdir -p ~/.claude
curl -fsSL https://raw.githubusercontent.com/mathpluscode/agent-statusline/main/claude_code.sh \
  -o ~/.claude/claude_code.sh
chmod +x ~/.claude/claude_code.sh

If curl fails, fall back to copying from a local clone if one exists; otherwise stop and report.

4. Write the new settings

JSON-aware merge into ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_NO_FLICKER": "1"
  },
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "SID=$(cat - | jq -r '.session_id') && date +%s > \"$HOME/.claude/last-user-input-$SID\""
          }
        ]
      }
    ]
  },
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/claude_code.sh",
    "refreshInterval": 10
  }
}

CLAUDE_CODE_NO_FLICKER=1 suppresses the terminal redraw flash on each refresh. Merge it into any existing env block rather than overwriting.

The hook powers the idle: segment by writing a per-session timestamp the script reads back. Without it, idle: just doesn't render.

5. Verify

  1. Re-read settings.json, confirm valid JSON and new keys present.
  2. Run bash ~/.claude/claude_code.sh < /dev/null — it must exit 0.
  3. Tell the user: setup complete, restart Claude Code for it to take effect.

Optional extras (only if asked or if relevant)

  • Starship prompt: if the user wants a complementary shell prompt, install Starship and apply the pure-preset preset (minimal — avoids duplicating dir/git info the statusline already shows). Skip if they already have a Starship config.