-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall-unix.sh
More file actions
80 lines (69 loc) · 2.19 KB
/
uninstall-unix.sh
File metadata and controls
80 lines (69 loc) · 2.19 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
#!/usr/bin/env bash
#
# Uninstall Python-NoAdmin on macOS and Linux.
# Removes the installation directory and cleans up shell profile entries.
#
set -euo pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { echo -e "${CYAN}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; }
INSTALL_DIR="${HOME}/.python-nonadmin"
echo ""
echo -e "${CYAN}============================================${NC}"
echo -e "${CYAN} Python-NoAdmin Uninstaller${NC}"
echo -e "${CYAN}============================================${NC}"
echo ""
# Confirm
read -p "This will remove Python-NoAdmin from $INSTALL_DIR. Continue? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
info "Uninstallation cancelled."
exit 0
fi
# Remove installation directory
if [ -d "$INSTALL_DIR" ]; then
info "Removing installation directory..."
rm -rf "$INSTALL_DIR"
success "Removed: $INSTALL_DIR"
else
warn "Installation directory not found: $INSTALL_DIR"
fi
# Clean shell profiles
clean_profile() {
local profile="$1"
if [ -f "$profile" ]; then
if grep -q "Python-NoAdmin" "$profile"; then
info "Cleaning: $profile"
# Create backup
cp "$profile" "${profile}.bak"
# Remove Python-NoAdmin lines
sed -i.tmp '/# Python-NoAdmin/,/# End Python-NoAdmin/d' "$profile"
rm -f "${profile}.tmp"
success "Cleaned: $profile (backup at ${profile}.bak)"
fi
fi
}
clean_profile "${HOME}/.bashrc"
clean_profile "${HOME}/.bash_profile"
clean_profile "${HOME}/.zshrc"
clean_profile "${HOME}/.profile"
# Fish config
FISH_CONFIG="${HOME}/.config/fish/config.fish"
if [ -f "$FISH_CONFIG" ] && grep -q "Python-NoAdmin" "$FISH_CONFIG"; then
info "Cleaning Fish config..."
cp "$FISH_CONFIG" "${FISH_CONFIG}.bak"
sed -i.tmp '/# Python-NoAdmin/,/# End Python-NoAdmin/d' "$FISH_CONFIG"
rm -f "${FISH_CONFIG}.tmp"
success "Cleaned: $FISH_CONFIG"
fi
echo ""
success "Python-NoAdmin has been uninstalled."
info "Restart your terminal for PATH changes to take effect."
echo ""