-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·152 lines (133 loc) · 6.28 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·152 lines (133 loc) · 6.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
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
149
150
151
152
#!/usr/bin/env bash
set -e
SKILL_DIR="$HOME/.claude/skills/cmux"
REPO="https://github.com/jhta/cmux-skill"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " cmux skill installer for Claude Code"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# ── Homebrew ──────────────────────────────────────────────────────────────────
if ! command -v brew &>/dev/null; then
echo "⚠️ Homebrew not found. Install it first: https://brew.sh"
exit 1
fi
# ── Neovim ────────────────────────────────────────────────────────────────────
if ! command -v nvim &>/dev/null; then
echo "→ Installing Neovim..."
brew install neovim
else
echo "✓ Neovim $(nvim --version | head -1 | awk '{print $2}')"
fi
# ── delta ─────────────────────────────────────────────────────────────────────
if ! command -v delta &>/dev/null; then
echo "→ Installing delta..."
brew install git-delta
else
echo "✓ delta $(delta --version | awk '{print $2}')"
fi
# ── cmux CLI symlink ──────────────────────────────────────────────────────────
CMUX_BIN="/Applications/cmux.app/Contents/Resources/bin/cmux"
if [[ -f "$CMUX_BIN" ]]; then
if [[ ! -f /usr/local/bin/cmux ]]; then
echo "→ Symlinking cmux CLI..."
sudo ln -sf "$CMUX_BIN" /usr/local/bin/cmux
else
echo "✓ cmux CLI already symlinked"
fi
else
echo "⚠️ cmux.app not found in /Applications — skipping CLI symlink."
echo " Download cmux at https://www.cmux.dev/ then re-run this script."
fi
# ── Clone skill ───────────────────────────────────────────────────────────────
if [[ -d "$SKILL_DIR/.git" ]]; then
echo "→ Updating existing skill..."
git -C "$SKILL_DIR" pull --ff-only
elif [[ -d "$SKILL_DIR" ]]; then
echo "⚠️ $SKILL_DIR exists but is not a git repo — skipping clone."
else
echo "→ Installing skill to $SKILL_DIR..."
mkdir -p "$(dirname "$SKILL_DIR")"
git clone "$REPO" "$SKILL_DIR"
fi
# ── Shell helpers (zshrc / bashrc) ────────────────────────────────────────────
SOURCE_LINE="source \$HOME/.claude/skills/cmux/scripts/cmux-helpers.sh"
SHELL_RC=""
if [[ "$SHELL" == */zsh ]]; then
SHELL_RC="$HOME/.zshrc"
elif [[ "$SHELL" == */bash ]]; then
SHELL_RC="$HOME/.bashrc"
fi
if [[ -n "$SHELL_RC" ]]; then
if grep -qF "cmux-helpers.sh" "$SHELL_RC" 2>/dev/null; then
echo "✓ Shell helpers already sourced in $SHELL_RC"
else
echo "→ Adding helpers to $SHELL_RC..."
echo "" >> "$SHELL_RC"
echo "# cmux skill helpers" >> "$SHELL_RC"
echo "$SOURCE_LINE" >> "$SHELL_RC"
fi
else
echo "⚠️ Unknown shell — add this manually to your rc file:"
echo " $SOURCE_LINE"
fi
# ── Claude Code hooks ─────────────────────────────────────────────────────────
HOOKS_DIR="$HOME/.claude/hooks"
SETTINGS="$HOME/.claude/settings.json"
mkdir -p "$HOOKS_DIR"
setup_hook() {
local name="$1" # e.g. stop
local event="$2" # e.g. Stop
local hook_file="$HOOKS_DIR/cmux-${name}.sh"
if [[ -f "$hook_file" ]]; then
echo "✓ Hook $event already exists"
return
fi
cat > "$hook_file" <<HOOKEOF
#!/usr/bin/env bash
if [[ -S "\${CMUX_SOCKET_PATH:-/tmp/cmux.sock}" ]]; then
cat | cmux claude-hook ${name} > /dev/null 2>&1 &
fi
exit 0
HOOKEOF
chmod +x "$hook_file"
# Inject into settings.json if not already present
if command -v jq &>/dev/null; then
if [[ ! -f "$SETTINGS" ]]; then
echo '{}' > "$SETTINGS"
fi
if ! jq -e ".hooks.${event}" "$SETTINGS" &>/dev/null; then
tmp=$(mktemp)
jq ".hooks.${event} = [{\"matcher\": \"*\", \"hooks\": [{\"type\": \"command\", \"command\": \"${hook_file}\"}]}]" \
"$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
echo "→ Registered $event hook in settings.json"
else
echo "⚠️ $event hook already in settings.json — add manually if needed:"
echo " $hook_file"
fi
else
echo "⚠️ jq not found — add hook manually to ~/.claude/settings.json:"
echo " $hook_file"
fi
}
setup_hook "stop" "Stop"
setup_hook "session-start" "SessionStart"
setup_hook "notification" "Notification"
# ── Git delta config ──────────────────────────────────────────────────────────
echo "→ Configuring git to use delta..."
git config --global core.pager delta
git config --global interactive.diffFilter "delta --color-only"
git config --global delta.navigate true
git config --global delta.dark true
git config --global delta.side-by-side true
git config --global delta.line-numbers true
git config --global merge.conflictstyle diff3
git config --global diff.colorMoved default
echo "✓ Git delta config applied"
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " ✅ Done! Run Claude Code inside cmux and"
echo " say things like:"
echo " • \"open the code\""
echo " • \"show me the diff\""
echo " • \"run the tests in a new pane\""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"