Instructions for Claude Code to execute. Follow in order.
- Platform: macOS or Linux. If Windows (non-WSL), stop.
jqinstalled (command -v jq). If missing, ask the user before installing via package manager.gitinstalled.
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
statusLineexists, remove it — clean replace, do not merge. - In
hooks.UserPromptSubmit, remove any prior entry whose command writes tolast-user-input-(old version of this hook). Leave unrelated hooks alone. - Preserve all other keys.
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.shIf curl fails, fall back to copying from a local clone if one exists; otherwise stop and report.
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.
- Re-read
settings.json, confirm valid JSON and new keys present. - Run
bash ~/.claude/claude_code.sh < /dev/null— it must exit 0. - Tell the user: setup complete, restart Claude Code for it to take effect.
- Starship prompt: if the user wants a complementary shell prompt, install Starship and apply the
pure-presetpreset (minimal — avoids duplicating dir/git info the statusline already shows). Skip if they already have a Starship config.