-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·171 lines (142 loc) · 4.15 KB
/
uninstall.sh
File metadata and controls
executable file
·171 lines (142 loc) · 4.15 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
#!/bin/bash
set -euo pipefail
# flow-cli uninstaller
# Cleanly removes flow-cli from your system
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/Data-Wise/flow-cli/main/uninstall.sh | bash
#
# Or run locally:
# bash uninstall.sh
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e "${YELLOW}==>${NC} $1"; }
success() { echo -e "${GREEN}✓${NC} $1"; }
warn() { echo -e "${YELLOW}!${NC} $1"; }
# Detect installation method
detect_installation() {
local zshrc="${ZDOTDIR:-$HOME}/.zshrc"
local plugins_file="${ZDOTDIR:-$HOME}/.zsh_plugins.txt"
# Check antidote
if [[ -f "$plugins_file" ]] && grep -q "flow-cli" "$plugins_file" 2>/dev/null; then
echo "antidote"
return
fi
# Check zinit
if grep -q "zinit.*flow-cli" "$zshrc" 2>/dev/null; then
echo "zinit"
return
fi
# Check oh-my-zsh
local omz_plugin="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/flow-cli"
if [[ -d "$omz_plugin" ]]; then
echo "omz"
return
fi
# Check manual
if [[ -d "$HOME/.flow-cli" ]]; then
echo "manual"
return
fi
echo "none"
}
# Remove from antidote
uninstall_antidote() {
info "Removing from antidote..."
local plugins_file="${ZDOTDIR:-$HOME}/.zsh_plugins.txt"
if [[ -f "$plugins_file" ]]; then
# Remove flow-cli lines (including comment)
sed -i.bak '/flow-cli/d' "$plugins_file"
rm -f "${plugins_file}.bak"
success "Removed from $plugins_file"
fi
# Remove cached plugin
local cache_dir="${ANTIDOTE_HOME:-$HOME/.cache/antidote}"
if [[ -d "$cache_dir" ]]; then
rm -rf "$cache_dir"/*flow-cli* 2>/dev/null || true
success "Cleared antidote cache"
fi
warn "Run 'antidote update' to complete removal"
}
# Remove from zinit
uninstall_zinit() {
info "Removing from zinit..."
local zshrc="${ZDOTDIR:-$HOME}/.zshrc"
if [[ -f "$zshrc" ]]; then
# Remove zinit flow-cli lines
sed -i.bak '/flow-cli/d' "$zshrc"
rm -f "${zshrc}.bak"
success "Removed from $zshrc"
fi
# Remove zinit plugin directory
local zinit_plugins="${ZINIT_HOME:-$HOME/.zinit}/plugins"
if [[ -d "$zinit_plugins" ]]; then
rm -rf "$zinit_plugins"/*flow-cli* 2>/dev/null || true
success "Removed zinit plugin files"
fi
}
# Remove from oh-my-zsh
uninstall_omz() {
info "Removing from oh-my-zsh..."
local plugin_dir="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/flow-cli"
if [[ -d "$plugin_dir" ]]; then
rm -rf "$plugin_dir"
success "Removed $plugin_dir"
fi
local zshrc="${ZDOTDIR:-$HOME}/.zshrc"
warn "Remember to remove 'flow-cli' from plugins=(...) in $zshrc"
}
# Remove manual installation
uninstall_manual() {
info "Removing manual installation..."
local install_dir="$HOME/.flow-cli"
local zshrc="${ZDOTDIR:-$HOME}/.zshrc"
if [[ -d "$install_dir" ]]; then
rm -rf "$install_dir"
success "Removed $install_dir"
fi
if [[ -f "$zshrc" ]]; then
# Remove source line
sed -i.bak '/flow.plugin.zsh/d' "$zshrc"
sed -i.bak '/flow-cli.*ZSH workflow/d' "$zshrc"
rm -f "${zshrc}.bak"
success "Removed from $zshrc"
fi
}
# Main uninstall flow
main() {
echo ""
echo -e "${BOLD}flow-cli uninstaller${NC}"
echo ""
local method
method=$(detect_installation)
if [[ "$method" == "none" ]]; then
warn "flow-cli installation not detected"
echo ""
echo "Checked locations:"
echo " - ~/.zsh_plugins.txt (antidote)"
echo " - ~/.zshrc (zinit)"
echo " - ~/.oh-my-zsh/custom/plugins/flow-cli"
echo " - ~/.flow-cli"
exit 0
fi
info "Detected installation: ${BOLD}${method}${NC}"
echo ""
case "$method" in
antidote) uninstall_antidote ;;
zinit) uninstall_zinit ;;
omz) uninstall_omz ;;
manual) uninstall_manual ;;
esac
echo ""
success "flow-cli has been uninstalled"
echo ""
echo "Restart your shell or run:"
echo " source ~/.zshrc"
echo ""
}
main "$@"