-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·54 lines (47 loc) · 1.84 KB
/
install.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.84 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
48
49
50
51
52
53
54
#!/bin/bash
set -eu
REPO="thevibeworks/claude-code-statusline"
BRANCH="main"
RAW="https://raw.githubusercontent.com/${REPO}/${BRANCH}"
DEST="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/statusline.sh"
SETTINGS="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/settings.json"
RED='\033[31m'; GREEN='\033[32m'; DIM='\033[2m'; RESET='\033[0m'
info() { printf "${GREEN}>>>${RESET} %s\n" "$*"; }
warn() { printf "${RED}>>>${RESET} %s\n" "$*" >&2; }
die() { warn "$@"; exit 1; }
command -v jq >/dev/null 2>&1 || die "jq is required: brew install jq / apt install jq"
command -v curl >/dev/null 2>&1 || die "curl is required"
info "Downloading statusline.sh"
curl -fsSL "${RAW}/statusline.sh" -o "$DEST"
chmod +x "$DEST"
info "Installed to $DEST"
_tilde='~'
STATUSLINE_CMD="bash ${DEST/#$HOME/$_tilde}"
if [ ! -f "$SETTINGS" ]; then
info "Creating $SETTINGS"
mkdir -p "$(dirname "$SETTINGS")"
cat > "$SETTINGS" << SETTINGSEOF
{
"statusLine": {
"type": "command",
"command": "$STATUSLINE_CMD",
"padding": 0
}
}
SETTINGSEOF
else
if jq -e '.statusLine' "$SETTINGS" >/dev/null 2>&1; then
info "statusLine already configured in $SETTINGS — updating command"
tmp="${SETTINGS}.tmp.$$"
jq --arg cmd "$STATUSLINE_CMD" '.statusLine.type = "command" | .statusLine.command = $cmd | .statusLine.padding = (.statusLine.padding // 0)' "$SETTINGS" > "$tmp"
mv -f "$tmp" "$SETTINGS"
else
info "Adding statusLine to $SETTINGS"
tmp="${SETTINGS}.tmp.$$"
jq --arg cmd "$STATUSLINE_CMD" '. + {"statusLine": {"type": "command", "command": $cmd, "padding": 0}}' "$SETTINGS" > "$tmp"
mv -f "$tmp" "$SETTINGS"
fi
fi
info "Done. Restart Claude Code or send a message to see the statusline."
printf "${DIM} Docs: https://github.com/${REPO}${RESET}\n"
printf "${DIM} Official: https://code.claude.com/docs/en/statusline${RESET}\n"