-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·81 lines (68 loc) · 2.28 KB
/
setup.sh
File metadata and controls
executable file
·81 lines (68 loc) · 2.28 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
#!/usr/bin/env bash
set -euo pipefail
REPO_URL="https://github.com/YoniChechik/claude-code-config.git"
CLAUDE_DIR="$HOME/.claude"
# --- Git-enable ~/.claude if not already a git repo ---
if [ ! -d "$CLAUDE_DIR/.git" ]; then
echo "==> Git-enabling $CLAUDE_DIR"
TMP_DIR="$(mktemp -d)"
git clone "$REPO_URL" "$TMP_DIR"
mv "$TMP_DIR/.git" "$CLAUDE_DIR/"
rm -rf "$TMP_DIR"
cd "$CLAUDE_DIR"
git reset --hard HEAD
echo " Done. Continuing setup from $CLAUDE_DIR"
fi
SCRIPT_DIR="$CLAUDE_DIR"
CHANNEL_DIR="$SCRIPT_DIR/channel"
MCP_TARGET="$HOME/.claude.json"
echo "==> Installing npm dependencies in $CHANNEL_DIR"
cd "$CHANNEL_DIR"
npm install
# --- Register webhook MCP server directly in ~/.claude.json (no .mcp.json file needed) ---
echo "==> Registering webhook MCP server in $MCP_TARGET"
node -e "$(cat <<'NODEJS'
const fs = require('fs');
const path = require('path');
const target = process.argv[1];
const homeDir = process.argv[2];
// Build the webhook MCP entry using $HOME so the path is portable
const webhookEntry = {
command: "npx",
args: ["tsx", path.join(homeDir, ".claude", "channel", "webhook.ts")]
};
// Load existing config or start fresh
let config = {};
if (fs.existsSync(target)) {
config = JSON.parse(fs.readFileSync(target, 'utf8'));
}
// Add/update the webhook entry under mcpServers
config.mcpServers = { ...config.mcpServers, webhook: webhookEntry };
fs.writeFileSync(target, JSON.stringify(config, null, 2) + '\n');
NODEJS
)" -- "$MCP_TARGET" "$HOME"
echo " Registered webhook MCP server in $MCP_TARGET"
# --- Update cc alias ---
NEW_ALIAS='alias cc='"'"'claude --dangerously-load-development-channels server:webhook'"'"''
update_alias() {
local rc_file="$1"
if [ ! -f "$rc_file" ]; then
return
fi
# Remove any existing cc alias line, then append the new one
if grep -q 'alias cc=' "$rc_file"; then
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' '/^alias cc=/d' "$rc_file"
else
sed -i '/^alias cc=/d' "$rc_file"
fi
fi
printf '%s\n' "$NEW_ALIAS" >> "$rc_file"
echo " Updated cc alias in $rc_file"
}
echo "==> Updating cc alias"
update_alias "$HOME/.zshrc"
update_alias "$HOME/.bashrc"
echo ""
echo "==> Done! Restart your shell or run: source ~/.zshrc"
echo " Then start Claude with: cc"