-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
47 lines (39 loc) · 1.26 KB
/
setup.sh
File metadata and controls
47 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -euo pipefail
# Build
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
cargo build --release
# Determine binary path
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
BIN="$SCRIPT_DIR/target/release/statusline.exe"
else
BIN="$SCRIPT_DIR/target/release/statusline"
fi
if [[ ! -f "$BIN" ]]; then
echo "ERROR: Build failed — binary not found at $BIN"
exit 1
fi
# Find ~/.claude/settings.json
CLAUDE_DIR="${HOME}/.claude"
SETTINGS="${CLAUDE_DIR}/settings.json"
mkdir -p "$CLAUDE_DIR"
# Normalize path for JSON (forward slashes)
BIN_JSON=$(echo "$BIN" | sed 's|\\|/|g')
if [[ -f "$SETTINGS" ]]; then
# Update or add statusLine using node (available on all platforms with Claude Code)
node -e "
const fs = require('fs');
const s = JSON.parse(fs.readFileSync('$SETTINGS', 'utf8'));
s.statusLine = { type: 'command', command: '$BIN_JSON' };
fs.writeFileSync('$SETTINGS', JSON.stringify(s, null, 2) + '\n');
"
else
node -e "
const fs = require('fs');
const s = { statusLine: { type: 'command', command: '$BIN_JSON' } };
fs.writeFileSync('$SETTINGS', JSON.stringify(s, null, 2) + '\n');
"
fi
echo "Done! statusline installed: $BIN_JSON"
echo "Restart Claude Code to apply."