-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·714 lines (642 loc) · 28.9 KB
/
uninstall.sh
File metadata and controls
executable file
·714 lines (642 loc) · 28.9 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
#!/usr/bin/env bash
set -uo pipefail
# =============================================================================
# Uninstall — Remove everything installed by CLI Maxxing
# Reverses all setup steps. Does NOT remove Homebrew, Git, nvm, or Node.js
# themselves — they are user tools and other things on the system likely
# depend on them. We only strip the specific lines/files WE wrote.
#
# On macOS, step-1 writes shell integrations to BOTH zsh + bash config files
# (.zshrc, .bashrc, .zprofile, .bash_profile) because Terminal.app defaults
# to zsh even when passwd says bash. Uninstall must clean all four.
#
# Usage: curl -fsSL <hosted-url>/uninstall.sh | bash
# =============================================================================
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
REMOVED=0
SKIPPED=0
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[REMOVED]${NC} $1"; REMOVED=$((REMOVED + 1)); }
skip() { echo -e "${YELLOW}[SKIP]${NC} $1"; SKIPPED=$((SKIPPED + 1)); }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
# -----------------------------------------------------------------------------
# source_runtime_path — hydrate brew/nvm/~/.local/bin into this shell so that
# `claude mcp remove`, `brew uninstall`, `npm uninstall`, etc. can actually
# find their binaries even if the parent shell never sourced its rc files.
# Idempotent — safe to call multiple times.
# -----------------------------------------------------------------------------
source_runtime_path() {
if command -v brew &>/dev/null; then
eval "$(brew shellenv)" 2>/dev/null || true
elif [ -x "/opt/homebrew/bin/brew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || true
elif [ -x "/usr/local/bin/brew" ]; then
eval "$(/usr/local/bin/brew shellenv)" 2>/dev/null || true
elif [ -x "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null || true
fi
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
if [ -s "$NVM_DIR/nvm.sh" ]; then
# shellcheck disable=SC1091
\. "$NVM_DIR/nvm.sh" 2>/dev/null || true
fi
if [ -d "$HOME/.local/bin" ]; then
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) export PATH="$HOME/.local/bin:$PATH" ;;
esac
fi
}
# -----------------------------------------------------------------------------
# detect_os — mirrors step-1's multi-shell detection so we clean the same set
# of rc + profile files that install wrote to.
# macOS: both zsh + bash (.zshrc, .bashrc, .zprofile, .bash_profile).
# Linux: single login shell via getent passwd.
# -----------------------------------------------------------------------------
detect_os() {
case "$(uname -s)" in
Darwin) OS="mac" ;;
Linux) OS="linux" ;;
*) OS="linux" ;; # best-effort for unknown Unixes
esac
if [ "$OS" = "mac" ]; then
SHELL_RCS=("$HOME/.zshrc" "$HOME/.bashrc")
SHELL_PROFILES=("$HOME/.zprofile" "$HOME/.bash_profile")
USER_SHELL="zsh+bash"
else
local login_shell=""
if command -v getent &>/dev/null; then
login_shell=$(getent passwd "$USER" 2>/dev/null | cut -d: -f7)
fi
if [ -z "$login_shell" ]; then
login_shell="${SHELL:-/bin/bash}"
fi
case "$login_shell" in
*/zsh)
USER_SHELL="zsh"
SHELL_RCS=("$HOME/.zshrc")
SHELL_PROFILES=("$HOME/.zprofile")
;;
*/bash|*)
USER_SHELL="bash"
SHELL_RCS=("$HOME/.bashrc")
SHELL_PROFILES=("$HOME/.bash_profile")
;;
esac
fi
info "Detected OS: $OS (shell targets: $USER_SHELL)"
info "Cleaning RC files: ${SHELL_RCS[*]}"
info "Cleaning profile files: ${SHELL_PROFILES[*]}"
}
# -----------------------------------------------------------------------------
# strip_line — delete every line matching $1 in file $2 (portable sed -i.bak)
# Silent no-op if file doesn't exist.
# -----------------------------------------------------------------------------
strip_line() {
local pattern="$1"
local file="$2"
[ -f "$file" ] || return 0
if grep -q "$pattern" "$file" 2>/dev/null; then
sed -i.bak "/$pattern/d" "$file" 2>/dev/null || true
rm -f "${file}.bak"
return 0
fi
return 1
}
# -----------------------------------------------------------------------------
# strip_block — delete from $1 through $2 (inclusive) in $3. Block-style sed.
# Used for multi-line things we wrote (g2/g4 function bodies).
# -----------------------------------------------------------------------------
strip_block() {
local start="$1"
local end="$2"
local file="$3"
[ -f "$file" ] || return 0
if grep -q "$start" "$file" 2>/dev/null; then
sed -i.bak "/$start/,/$end/d" "$file" 2>/dev/null || true
rm -f "${file}.bak"
return 0
fi
return 1
}
# -----------------------------------------------------------------------------
# confirm_uninstall — preserve existing "this will remove stuff" banner and
# give the user one last chance to bail if running interactively.
# -----------------------------------------------------------------------------
confirm_uninstall() {
echo ""
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${RED} Uninstall — CLI Maxxing${NC}"
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo " This will remove tools and configurations installed by"
echo " CLI Maxxing (all steps). Your Obsidian vault, notes,"
echo " Homebrew, Node.js, and user-installed skills will NOT be deleted."
echo ""
# Only prompt when stdin is a TTY. curl|bash installs run non-interactively
# and should proceed without prompting (same pattern as install.sh).
if [ -t 0 ]; then
read -r -p " Continue? [y/N] " reply
case "$reply" in
[yY]|[yY][eE][sS]) ;;
*) echo " Aborted."; exit 0 ;;
esac
echo ""
fi
}
# -----------------------------------------------------------------------------
# Final Step — Status Line
# -----------------------------------------------------------------------------
uninstall_status_line() {
echo -e "${BLUE}--- Final Step: Status Line ---${NC}"
if [ -f "$HOME/.claude/statusline.sh" ]; then
rm -f "$HOME/.claude/statusline.sh"
success "Status line script"
else
skip "Status line script (not found)"
fi
# Remove the statusLine key from settings.json via jq (CLAUDE.md rule:
# always jq-merge, never overwrite). If jq isn't available, fall back to
# a notice — the user can either install jq or clear the field manually.
# IMPORTANT: run this BEFORE uninstall_dev_tools, which removes jq itself.
local settings="$HOME/.claude/settings.json"
if [ -f "$settings" ]; then
if grep -q '"statusLine"' "$settings" 2>/dev/null; then
if command -v jq &>/dev/null; then
if jq 'del(.statusLine)' "$settings" > "${settings}.tmp" 2>/dev/null; then
mv "${settings}.tmp" "$settings" 2>/dev/null || true
success "statusLine key removed from $settings"
else
rm -f "${settings}.tmp" 2>/dev/null || true
warn "Could not strip statusLine from $settings — remove the key manually"
fi
else
warn "jq not available — remove the \"statusLine\" key from $settings manually"
fi
else
skip "statusLine key (not found in settings.json)"
fi
else
skip "settings.json (not found — nothing to strip)"
fi
}
# -----------------------------------------------------------------------------
# Step 8 — Safety Check
# -----------------------------------------------------------------------------
uninstall_safetycheck() {
echo ""
echo -e "${BLUE}--- Step 8: Safety Check ---${NC}"
if [ -d "$HOME/.claude/skills/safetycheck" ]; then
rm -rf "$HOME/.claude/skills/safetycheck"
success "SafetyCheck skill (~/.claude/skills/safetycheck)"
else
skip "SafetyCheck skill (not found)"
fi
}
# -----------------------------------------------------------------------------
# Step 7 — GitHub MCP + /gitfix + /recon
# -----------------------------------------------------------------------------
uninstall_github() {
echo ""
echo -e "${BLUE}--- Step 7: GitHub CLI + MCP + /gitfix + /recon ---${NC}"
# gh CLI — installed by Step 7 (pre-2026-04 installs had it in Step 3, so
# removal here catches both layouts).
if command -v gh &>/dev/null || brew list gh &>/dev/null 2>&1; then
brew uninstall gh 2>/dev/null || true
success "brew: gh (GitHub CLI)"
else
skip "brew: gh (not found)"
fi
# Anchor on "^github:" so we only match the MCP we actually registered,
# not user-defined ones like "my-github-fork" or "github-enterprise".
if claude mcp list 2>/dev/null | grep -qE '^github:' 2>/dev/null; then
claude mcp remove github 2>/dev/null || true
success "GitHub MCP"
else
skip "GitHub MCP (not found)"
fi
if [ -d "$HOME/.claude/skills/gitfix" ]; then
rm -rf "$HOME/.claude/skills/gitfix"
success "Skill: /gitfix"
else
skip "Skill: /gitfix (not found)"
fi
if [ -d "$HOME/.claude/skills/recon" ]; then
rm -rf "$HOME/.claude/skills/recon"
success "Skill: /recon"
else
skip "Skill: /recon (not found)"
fi
}
# -----------------------------------------------------------------------------
# Step 6 — Telegram
# -----------------------------------------------------------------------------
uninstall_telegram() {
echo ""
echo -e "${BLUE}--- Step 6: Telegram ---${NC}"
if [ -d "$HOME/.claude/channels/telegram" ]; then
rm -rf "$HOME/.claude/channels/telegram"
success "Telegram config directory (~/.claude/channels/telegram)"
else
skip "Telegram config directory (not found)"
fi
}
# -----------------------------------------------------------------------------
# Step 5 — Productivity Tools
# (Notion, Granola, n8n, Google Calendar, Morgen, Motion Calendar, Playwright,
# SwiftKit, Superhuman, Google Drive, Vercel)
# -----------------------------------------------------------------------------
uninstall_productivity_mcps() {
echo ""
echo -e "${BLUE}--- Step 5: Productivity Tools ---${NC}"
for mcp in notion granola n8n google-calendar morgen motion playwright swiftkit superhuman gdrive vercel; do
# Anchor on "^<mcp>:" so we only match the MCP we registered under
# that exact name — avoids matching user-defined MCPs that reuse the
# same underlying package (e.g. a custom "my-notion" wrapper).
if claude mcp list 2>/dev/null | grep -qE "^${mcp}:" 2>/dev/null; then
claude mcp remove "$mcp" 2>/dev/null || true
success "$mcp MCP"
else
skip "$mcp MCP (not found)"
fi
done
# Google Calendar config
if [ -d "$HOME/.google-calendar-mcp" ]; then
rm -rf "$HOME/.google-calendar-mcp"
success "Google Calendar config (~/.google-calendar-mcp)"
else
skip "Google Calendar config (not found)"
fi
# Motion Calendar config
if [ -d "$HOME/.motion-mcp" ]; then
rm -rf "$HOME/.motion-mcp"
success "Motion Calendar config (~/.motion-mcp)"
else
skip "Motion Calendar config (not found)"
fi
}
# -----------------------------------------------------------------------------
# Step 4 — FidgetFlo + skills
# -----------------------------------------------------------------------------
uninstall_fidgetflo_stack() {
echo ""
echo -e "${BLUE}--- Step 4: FidgetFlo ---${NC}"
# FidgetFlo MCP — anchor on "^fidgetflo:" so a substring in another MCP's
# command (the package name also contains "fidgetflo") can't false-positive.
if claude mcp list 2>/dev/null | grep -qE '^fidgetflo:' 2>/dev/null; then
claude mcp remove fidgetflo 2>/dev/null || true
success "FidgetFlo MCP server"
else
skip "FidgetFlo MCP server (not found)"
fi
# Claude-flow MCP — anchor to avoid matching e.g. "claude-flow-v3" forks.
if claude mcp list 2>/dev/null | grep -qE '^claude-flow:' 2>/dev/null; then
claude mcp remove claude-flow 2>/dev/null || true
success "Claude-flow MCP server"
else
skip "Claude-flow MCP server (not found)"
fi
# Global npm packages installed by step-4. Deliberately does NOT touch
# typescript — it's a user tool and many other things may depend on it.
for pkg in fidgetflo@latest agentic-flow@latest; do
PKG_NAME="${pkg//@latest/}"
if npm list -g "$PKG_NAME" 2>/dev/null | grep -q "$PKG_NAME"; then
npm uninstall -g "$PKG_NAME" 2>/dev/null || true
success "npm: $PKG_NAME"
else
skip "npm: $PKG_NAME (not found)"
fi
done
# cli-maxxing-installed skill files. User-installed skills not in this list
# (design-taste-*, high-end-visual-design, /save, /wiki, etc.) are preserved.
for skill in \
fswarm fswarm1 fswarm2 fswarm3 fswarmmax \
fmini fmini1 fmini2 fmini3 fminimax \
fhive w4w concise bullets; do
if [ -d "$HOME/.claude/skills/$skill" ]; then
rm -rf "$HOME/.claude/skills/$skill"
success "Skill: /$skill"
else
skip "Skill: /$skill (not found)"
fi
done
# Claude-flow config directory (created by step-3 npx init)
if [ -d "$HOME/.claude-flow" ]; then
rm -rf "$HOME/.claude-flow"
success ".claude-flow config directory"
else
skip ".claude-flow config (not found)"
fi
}
# -----------------------------------------------------------------------------
# Step 3 — Developer & Utility Tools (brew packages)
# -----------------------------------------------------------------------------
uninstall_dev_tools() {
echo ""
echo -e "${BLUE}--- Step 3: Developer & Utility Tools ---${NC}"
for tool in pandoc poppler jq ripgrep tree fzf wget weasyprint; do
if command -v "$tool" &>/dev/null || brew list "$tool" &>/dev/null 2>&1; then
brew uninstall "$tool" 2>/dev/null || true
success "brew: $tool"
else
skip "brew: $tool (not found)"
fi
done
# xlsx2csv — step-3 installs this via `pipx install xlsx2csv`, NOT via plain
# pip, because modern macOS Python trips PEP 668 (externally-managed-env).
# The old `python3 -c "import xlsx2csv"` probe always failed because pipx
# keeps the package in an isolated venv the user's python3 can't see.
# Detect via the CLI shim on PATH, then try pipx first (its own isolated
# venv is where step-3 put it), falling back to pip for pre-pipx legacy
# installs. Both commands are quiet-on-missing, so the fallback is safe.
if command -v xlsx2csv &>/dev/null; then
local removed=false
if command -v pipx &>/dev/null; then
if pipx uninstall xlsx2csv &>/dev/null; then
success "pipx: xlsx2csv"
removed=true
fi
fi
if [ "$removed" = "false" ]; then
if python3 -m pip uninstall xlsx2csv -y &>/dev/null; then
success "pip: xlsx2csv (legacy install)"
else
warn "xlsx2csv found on PATH but could not be removed via pipx or pip"
fi
fi
else
skip "xlsx2csv (not found)"
fi
}
# -----------------------------------------------------------------------------
# Bonus — Ghostty (config + cask + duti)
# Mirrors uninstall_arc — step-2/ghostty-install.sh runs `brew install --cask
# ghostty`, so if the cask is registered with brew we clean it up here. Users
# who installed Ghostty manually (direct download) keep the app; only the
# Homebrew-tracked cask is removed.
# -----------------------------------------------------------------------------
uninstall_ghostty() {
echo ""
echo -e "${BLUE}--- Bonus: Ghostty ---${NC}"
GHOSTTY_CONFIG_MAC="$HOME/Library/Application Support/com.mitchellh.ghostty/config"
GHOSTTY_CONFIG_LINUX="$HOME/.config/ghostty/config"
if [ -f "$GHOSTTY_CONFIG_MAC" ]; then
rm -f "$GHOSTTY_CONFIG_MAC"
rm -f "${GHOSTTY_CONFIG_MAC}.backup"
success "Ghostty config (macOS)"
elif [ -f "$GHOSTTY_CONFIG_LINUX" ]; then
rm -f "$GHOSTTY_CONFIG_LINUX"
rm -f "${GHOSTTY_CONFIG_LINUX}.backup"
success "Ghostty config (Linux)"
else
skip "Ghostty config (not found)"
fi
# Ghostty app — only remove when installed via the brew cask (step-2 path).
# Mirrors the Arc cleanup: app removed only if brew is the owner.
if [ -d "/Applications/Ghostty.app" ] && brew list --cask ghostty &>/dev/null 2>&1; then
brew uninstall --cask ghostty 2>/dev/null || true
success "Ghostty app (brew cask)"
else
skip "Ghostty app (not found or not installed via Homebrew)"
fi
# JetBrains Mono font — installed by step-2/ghostty-install.sh as a cask.
if brew list --cask font-jetbrains-mono &>/dev/null 2>&1; then
brew uninstall --cask font-jetbrains-mono 2>/dev/null || true
success "font: JetBrains Mono (brew cask)"
else
skip "font: JetBrains Mono (not found or not installed via Homebrew)"
fi
# duti (installed by step-2/ghostty-install.sh)
if brew list duti &>/dev/null 2>&1; then
brew uninstall duti 2>/dev/null || true
success "brew: duti"
else
skip "brew: duti (not found)"
fi
}
# -----------------------------------------------------------------------------
# Step 2 — Arc Browser (remove the app if installed via step-2/arc-install.sh)
# -----------------------------------------------------------------------------
uninstall_arc() {
echo ""
echo -e "${BLUE}--- Bonus: Arc Browser ---${NC}"
if [ -d "/Applications/Arc.app" ] && brew list --cask arc &>/dev/null 2>&1; then
brew uninstall --cask arc 2>/dev/null || true
success "Arc Browser (brew cask)"
else
skip "Arc Browser (not found or not installed via Homebrew)"
fi
}
# -----------------------------------------------------------------------------
# Step 1 — Claude Code, aliases, commands, shell integrations
# Clean every file in SHELL_RCS (.zshrc + .bashrc on macOS) and SHELL_PROFILES
# (.zprofile + .bash_profile on macOS). Only strip lines WE wrote, keyed on
# either the marker comment we own or the specific alias/export names we added.
# -----------------------------------------------------------------------------
uninstall_step_1() {
echo ""
echo -e "${BLUE}--- Step 1: Claude Code + Shortcuts ---${NC}"
# Claude Code global npm package. Don't remove Node/nvm — user tool.
if command -v claude &>/dev/null; then
npm uninstall -g @anthropic-ai/claude-code 2>/dev/null \
|| sudo npm uninstall -g @anthropic-ai/claude-code 2>/dev/null || true
success "Claude Code"
else
skip "Claude Code (not found)"
fi
# -------------------------------------------------------------------------
# Clean RC files (.zshrc / .bashrc — interactive shell config)
# -------------------------------------------------------------------------
local rc_alias_removed=0
local rc_flicker_removed=0
local rc_localbin_removed=0
local rc_ghostty_removed=0
for rc in "${SHELL_RCS[@]}"; do
[ -f "$rc" ] || continue
# Header marker we wrote ("# Claude Code shortcuts") — safe to delete,
# it's unique to us.
strip_line '# Claude Code shortcuts' "$rc"
# Aliases — only the exact names step-1 wrote. User's own aliases with
# different names stay.
for alias_name in cskip cc ccr ccc; do
if strip_line "alias ${alias_name}=" "$rc"; then
rc_alias_removed=$((rc_alias_removed + 1))
fi
done
# Also remove the old deprecated `alias ctg=` in case it's still around
# (step-1 migrates this to ~/.local/bin/ctg, but older installs may
# still have the alias line).
strip_line 'alias ctg=' "$rc"
# No-flicker env vars + marker we wrote
for flicker_pat in 'CLAUDE_CODE_NO_FLICKER' 'CLAUDE_CODE_SCROLL_SPEED' '# Claude Code — no-flicker'; do
if strip_line "$flicker_pat" "$rc"; then
rc_flicker_removed=$((rc_flicker_removed + 1))
fi
done
# ~/.local/bin PATH entry — OUR marker "# Local bin (ctg" is unique.
# Remove the marker line AND the export on the next line if it matches
# what we wrote. We only strip a bare `export PATH="$HOME/.local/bin:$PATH"`
# — user's more elaborate PATH lines (with extra paths) are left alone.
if grep -q '# Local bin (ctg' "$rc" 2>/dev/null; then
strip_line '# Local bin (ctg' "$rc"
# shellcheck disable=SC2016 # single quotes intentional: pattern is a sed regex, not shell expansion
strip_line '^export PATH="\$HOME/\.local/bin:\$PATH"$' "$rc"
rc_localbin_removed=$((rc_localbin_removed + 1))
fi
# g2 / g4 Ghostty window-tiling functions — WE wrote these as
# multi-line function bodies under a `# Ghostty window tiling` header.
if grep -q '# Ghostty window tiling' "$rc" 2>/dev/null \
|| grep -q '^g2()' "$rc" 2>/dev/null \
|| grep -q '^g4()' "$rc" 2>/dev/null; then
strip_block '# Ghostty window tiling' '^}' "$rc"
strip_block '^g2()' '^}' "$rc"
strip_block '^g4()' '^}' "$rc"
rc_ghostty_removed=$((rc_ghostty_removed + 1))
fi
done
if [ "$rc_alias_removed" -gt 0 ]; then
success "Shell aliases ($rc_alias_removed removed across ${SHELL_RCS[*]})"
else
skip "Shell aliases (not found in any rc file)"
fi
if [ "$rc_flicker_removed" -gt 0 ]; then
success "No-flicker mode ($rc_flicker_removed lines removed across ${SHELL_RCS[*]})"
else
skip "No-flicker mode (not found in any rc file)"
fi
if [ "$rc_localbin_removed" -gt 0 ]; then
success "\$HOME/.local/bin PATH entry removed from $rc_localbin_removed rc file(s)"
else
skip "\$HOME/.local/bin PATH entry (not found in any rc file)"
fi
if [ "$rc_ghostty_removed" -gt 0 ]; then
success "g2/g4 window tiling functions removed from $rc_ghostty_removed rc file(s)"
else
skip "g2/g4 window tiling (not found in any rc file)"
fi
# -------------------------------------------------------------------------
# Clean profile files (.zprofile / .bash_profile — login shell config)
# Only the Homebrew shellenv block step-1 wrote under its `# Homebrew`
# marker. If brew was installed some other way, the user's own setup
# stays intact.
# -------------------------------------------------------------------------
local profile_brew_removed=0
for profile in "${SHELL_PROFILES[@]}"; do
[ -f "$profile" ] || continue
# Only strip if OUR marker is present. Homebrew's own installer writes
# a similar line but without this exact single-word `# Homebrew` header
# that step-1 uses.
if grep -q '^# Homebrew$' "$profile" 2>/dev/null \
&& grep -q 'brew shellenv' "$profile" 2>/dev/null; then
strip_line '^# Homebrew$' "$profile"
# shellcheck disable=SC2016 # single quotes intentional: patterns are sed regexes, not shell expansion
strip_line 'eval "\$(/opt/homebrew/bin/brew shellenv)"' "$profile"
# shellcheck disable=SC2016 # single quotes intentional: pattern is a sed regex, not shell expansion
strip_line 'eval "\$(/usr/local/bin/brew shellenv)"' "$profile"
profile_brew_removed=$((profile_brew_removed + 1))
fi
done
if [ "$profile_brew_removed" -gt 0 ]; then
success "Homebrew shellenv block removed from $profile_brew_removed profile file(s)"
else
skip "Homebrew shellenv block (not found or installed by a different tool — leaving alone)"
fi
# -------------------------------------------------------------------------
# ctg command (~/.local/bin script). cbrain/cbraintg are managed by the
# companion 2ndBrain-mogging installer — we don't touch those.
# -------------------------------------------------------------------------
if [ -f "$HOME/.local/bin/ctg" ]; then
rm -f "$HOME/.local/bin/ctg"
success "ctg command"
else
skip "ctg command (not found)"
fi
# -------------------------------------------------------------------------
# cli-maxxing breadcrumbs directory (step-N.done sentinels)
# -------------------------------------------------------------------------
if [ -d "$HOME/.cli-maxxing" ]; then
rm -rf "$HOME/.cli-maxxing"
success "cli-maxxing breadcrumbs (~/.cli-maxxing)"
else
skip "cli-maxxing breadcrumbs (~/.cli-maxxing not found)"
fi
}
# -----------------------------------------------------------------------------
# Optional heavy deps notice (brew / nvm / node) — we never auto-remove these
# -----------------------------------------------------------------------------
print_heavy_deps_notice() {
echo ""
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW} Optional: Core Dependencies${NC}"
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo " The following were installed by Step 1 but are commonly"
echo " used by other tools. They were NOT removed automatically:"
echo ""
echo " • Node.js / nvm"
echo " • Homebrew"
echo " • Git (usually pre-installed)"
echo ""
echo " To remove them manually:"
echo ""
echo -e " ${GREEN}nvm uninstall --lts${NC} # Remove Node.js"
echo -e " ${GREEN}/bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)\"${NC}"
echo " # Remove Homebrew"
echo ""
}
# -----------------------------------------------------------------------------
# Summary
# -----------------------------------------------------------------------------
print_summary() {
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${RED} Uninstall Complete${NC}"
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo " Removed: $REMOVED items"
echo " Skipped: $SKIPPED items (already absent)"
echo ""
echo " Your Obsidian vault and notes were NOT touched."
echo " The cbraintg command was NOT removed — it is managed by the"
echo " 2ndBrain-mogging companion installer. To remove it, run:"
echo " bash <(curl -fsSL https://raw.githubusercontent.com/fidgetcoding/2ndBrain-mogging/main/uninstall.sh)"
echo ""
echo " To finish cleanup, restart your terminal or re-source your shell:"
echo ""
if [ "${#SHELL_RCS[@]}" -gt 1 ]; then
echo " macOS writes to both zsh + bash configs — source whichever"
echo " shell you're actually using:"
echo ""
for rc in "${SHELL_RCS[@]}"; do
echo -e " ${GREEN}source $rc${NC}"
done
else
echo -e " ${GREEN}source ${SHELL_RCS[0]}${NC}"
fi
echo ""
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
}
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
main() {
source_runtime_path
detect_os
confirm_uninstall
uninstall_status_line
uninstall_safetycheck
uninstall_github
uninstall_telegram
uninstall_productivity_mcps
uninstall_fidgetflo_stack
uninstall_dev_tools
uninstall_ghostty
uninstall_arc
uninstall_step_1
print_heavy_deps_notice
print_summary
}
main "$@"