Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·148 lines (128 loc) · 4.95 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·148 lines (128 loc) · 4.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# Installs Claude Code statusline and the usage-limits plugin.
#
# Two install modes:
# LOCAL — run from a cloned repo: ./install.sh
# REMOTE — via curl one-liner: curl -fsSL <url>/install.sh | bash
set -euo pipefail
# ── Constants ─────────────────────────────────────────────────────────────────
if [ -n "${SUDO_USER:-}" ]; then
HOME="$(eval echo "~$SUDO_USER")"
fi
GITHUB_RAW="https://raw.githubusercontent.com/sholub-dev/cc-setup/master"
INSTALL_DIR="$HOME/.claude/extensions/cc-setup"
# ── Detect install mode ──────────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd || echo "")"
if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/statusline.sh" ]; then
MODE="local"
REPO_DIR="$SCRIPT_DIR"
echo "Detected local repo at $REPO_DIR"
else
MODE="remote"
echo "Remote install — downloading files to $INSTALL_DIR"
fi
# ── Pre-flight checks ────────────────────────────────────────────────────────
ERRORS=0
if ! command -v jq &>/dev/null; then
if command -v brew &>/dev/null; then
echo "⚠ jq not found — installing via Homebrew..."
brew install jq
echo "✓ jq installed"
else
echo "✗ jq not found and Homebrew not available"
echo " Install: brew install jq (or visit https://jqlang.github.io/jq/)"
ERRORS=$((ERRORS + 1))
fi
else
echo "✓ jq found"
fi
if [ "$ERRORS" -gt 0 ]; then
echo ""
echo "Fix the above issues and re-run the installer."
exit 1
fi
# ── Install ──────────────────────────────────────────────────────────────────
echo ""
mkdir -p "$INSTALL_DIR"
if [ "$MODE" = "remote" ]; then
echo "Downloading files..."
if curl -fsSL "$GITHUB_RAW/statusline.sh" > "$INSTALL_DIR/statusline.sh"; then
echo " ✓ statusline.sh"
else
echo " ✗ Failed to download statusline.sh"
exit 1
fi
elif [ "$MODE" = "local" ]; then
cp "$REPO_DIR/statusline.sh" "$INSTALL_DIR/"
echo "✓ Copied statusline.sh to $INSTALL_DIR"
fi
chmod +x "$INSTALL_DIR/statusline.sh"
echo "✓ Made statusline.sh executable"
# Symlink statusline.sh into ~/.claude/
ln -sf "$INSTALL_DIR/statusline.sh" "$HOME/.claude/statusline.sh"
echo "✓ Symlinked statusline.sh → ~/.claude/statusline.sh"
# Configure Claude Code settings
SETTINGS="$HOME/.claude/settings.json"
if [ -f "$SETTINGS" ]; then
TMP=$(mktemp)
jq '.statusLine = {"type":"command","command":"~/.claude/statusline.sh","padding":0}' "$SETTINGS" > "$TMP" && mv "$TMP" "$SETTINGS"
echo "✓ Updated Claude Code settings"
else
mkdir -p "$HOME/.claude"
cat > "$SETTINGS" <<'SETTINGS_JSON'
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh",
"padding": 0
}
}
SETTINGS_JSON
echo "✓ Created Claude Code settings"
fi
# Install the usage-limits plugin from this repository's marketplace.
# A local repo is added as a folder marketplace, so edits reach sessions after /reload-plugins.
if command -v claude &>/dev/null; then
if [ "$MODE" = "local" ]; then
MARKETPLACE_SOURCE="$REPO_DIR"
else
MARKETPLACE_SOURCE="sholub-dev/cc-setup"
fi
claude plugin marketplace add "$MARKETPLACE_SOURCE" >/dev/null 2>&1 || true
if claude plugin install usage-limits@cc-setup --scope user >/dev/null 2>&1; then
echo "✓ Installed usage-limits plugin"
else
echo "⚠ Could not install usage-limits plugin — run: claude plugin install usage-limits@cc-setup"
fi
else
echo "⚠ claude CLI not found — skipped usage-limits plugin"
fi
# ── Post-install verification ────────────────────────────────────────────────
echo ""
echo "Verification:"
PASS=0
FAIL=0
# statusline.sh is executable
if [ -x "$INSTALL_DIR/statusline.sh" ]; then
echo " ✓ statusline.sh is executable"
PASS=$((PASS + 1))
else
echo " ✗ statusline.sh is not executable"
FAIL=$((FAIL + 1))
fi
# settings.json contains statusLine
if jq -e '.statusLine' "$SETTINGS" >/dev/null 2>&1; then
echo " ✓ settings.json contains statusLine config"
PASS=$((PASS + 1))
else
echo " ✗ settings.json missing statusLine config"
FAIL=$((FAIL + 1))
fi
echo ""
echo "$PASS passed, $FAIL failed"
if [ "$FAIL" -gt 0 ]; then
echo "Some checks failed — review the output above."
exit 1
fi
echo ""
echo "Done! Open a Claude Code session — you should see the statusline."