-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·191 lines (173 loc) · 5.86 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·191 lines (173 loc) · 5.86 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
# stack-nudge uninstaller
#
# macOS users: prefer the in-app uninstall — open the panel via your
# hotkey (default ⌘⌥N), go to Settings, click "Uninstall stack-nudge…".
# It removes the same things this script does (hooks, launchd agents,
# ~/.stack-nudge/) plus trashes the .app.
#
# This script remains as a fallback for Linux/Windows + source-build
# macOS dev cycles, and as a safety net if the in-app uninstall fails
# partway and leaves state behind.
set -e
INSTALL_DIR="${HOME}/.stack-nudge"
echo "Uninstalling stack-nudge..."
# Remove hooks from Claude Code. Matches anything inside a `tinynudge` or
# `stack-nudge` install dir — including quoted forms like
# `"$HOME/.stack-nudge/notify.sh"` — so legacy entries (and dev checkouts
# pointing at moved paths) get cleaned up too, not just the current $NOTIFY.
if [[ -f "$HOME/.claude/settings.json" ]]; then
python3 - "$HOME/.claude/settings.json" <<'PY'
import json, re, sys
from pathlib import Path
path = Path(sys.argv[1])
STALE = re.compile(r'(?:^|/|")\.?(?:tinynudge|stack-nudge)/notify\.sh')
settings = json.loads(path.read_text())
hooks = settings.get("hooks", {})
for event in list(hooks.keys()):
cleaned = []
for g in hooks[event]:
inner = g.get("hooks", [])
kept = [h for h in inner if not STALE.search(h.get("command", "") or "")]
if not kept:
continue
if kept != inner:
g = {**g, "hooks": kept}
cleaned.append(g)
hooks[event] = cleaned
if not hooks[event]:
del hooks[event]
if not hooks:
settings.pop("hooks", None)
path.write_text(json.dumps(settings, indent=2) + "\n")
print(f" Cleaned {path}")
PY
fi
# Remove hooks from Cursor. Same path-agnostic match as the Claude block.
if [[ -f "$HOME/.cursor/hooks.json" ]]; then
python3 - "$HOME/.cursor/hooks.json" <<'PY'
import json, re, sys
from pathlib import Path
path = Path(sys.argv[1])
STALE = re.compile(r'(?:^|/|")\.?(?:tinynudge|stack-nudge)/notify\.sh')
settings = json.loads(path.read_text())
hooks = settings.get("hooks", {})
for event in list(hooks.keys()):
hooks[event] = [h for h in hooks[event] if not STALE.search(h.get("command", "") or "")]
if not hooks[event]:
del hooks[event]
if not hooks:
settings.pop("hooks", None)
path.write_text(json.dumps(settings, indent=2) + "\n")
print(f" Cleaned {path}")
PY
fi
# Remove hooks from Gemini CLI.
if [[ -f "$HOME/.gemini/settings.json" ]]; then
python3 - "$HOME/.gemini/settings.json" <<'PY'
import json, re, sys
from pathlib import Path
path = Path(sys.argv[1])
STALE = re.compile(r'(?:^|/|")\.?(?:tinynudge|stack-nudge)/notify\.sh')
settings = json.loads(path.read_text())
hooks = settings.get("hooks", {})
for event in list(hooks.keys()):
cleaned = []
for g in hooks[event]:
inner = g.get("hooks", [])
kept = [h for h in inner if not STALE.search(h.get("command", "") or "")]
if not kept:
continue
if kept != inner:
g = {**g, "hooks": kept}
cleaned.append(g)
hooks[event] = cleaned
if not hooks[event]:
del hooks[event]
if not hooks:
settings.pop("hooks", None)
path.write_text(json.dumps(settings, indent=2) + "\n")
print(f" Cleaned {path}")
PY
fi
# Remove hooks from Antigravity CLI.
if [[ -f "$HOME/.gemini/antigravity-cli/settings.json" ]]; then
python3 - "$HOME/.gemini/antigravity-cli/settings.json" <<'PY'
import json, re, sys
from pathlib import Path
path = Path(sys.argv[1])
STALE = re.compile(r'(?:^|/|")\.?(?:tinynudge|stack-nudge)/notify\.sh')
settings = json.loads(path.read_text())
hooks = settings.get("hooks", {})
for event in list(hooks.keys()):
cleaned = []
for g in hooks[event]:
inner = g.get("hooks", [])
kept = [h for h in inner if not STALE.search(h.get("command", "") or "")]
if not kept:
continue
if kept != inner:
g = {**g, "hooks": kept}
cleaned.append(g)
hooks[event] = cleaned
if not hooks[event]:
del hooks[event]
if not hooks:
settings.pop("hooks", None)
path.write_text(json.dumps(settings, indent=2) + "\n")
print(f" Cleaned {path}")
PY
fi
# Remove hooks from Codex. Same matcher-group shape as Claude/Gemini.
if [[ -f "$HOME/.codex/hooks.json" ]]; then
python3 - "$HOME/.codex/hooks.json" <<'PY'
import json, re, sys
from pathlib import Path
path = Path(sys.argv[1])
STALE = re.compile(r'(?:^|/|")\.?(?:tinynudge|stack-nudge)/notify\.sh')
settings = json.loads(path.read_text())
hooks = settings.get("hooks", {})
for event in list(hooks.keys()):
cleaned = []
for g in hooks[event]:
inner = g.get("hooks", [])
kept = [h for h in inner if not STALE.search(h.get("command", "") or "")]
if not kept:
continue
if kept != inner:
g = {**g, "hooks": kept}
cleaned.append(g)
hooks[event] = cleaned
if not hooks[event]:
del hooks[event]
if not hooks:
settings.pop("hooks", None)
path.write_text(json.dumps(settings, indent=2) + "\n")
print(f" Cleaned {path}")
PY
fi
# Stop and remove launchd agents (macOS)
for label in com.stackonehq.stack-nudge com.stackonehq.stack-nudge-daemon com.stackonehq.stack-nudge-panel; do
plist="$HOME/Library/LaunchAgents/${label}.plist"
if [[ -f "$plist" ]]; then
launchctl unload "$plist" 2>/dev/null || true
rm -f "$plist"
echo " Removed launchd agent ($label)"
fi
done
# Stop any running app process the launchd agent didn't catch
pkill -f "stack-nudge$" 2>/dev/null || true
# Remove app bundles (including old two-binary setup)
for app in StackNudge.app stack-nudge.app stack-nudge-panel.app; do
if [[ -d "$HOME/Applications/$app" ]]; then
rm -rf "$HOME/Applications/$app"
echo " Removed ~/Applications/$app"
fi
done
# Remove install dir (includes venv and notify.sh)
if [[ -d "$INSTALL_DIR" ]]; then
rm -rf "$INSTALL_DIR"
echo " Removed $INSTALL_DIR"
fi
echo ""
echo "Done."