-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
57 lines (51 loc) · 1.56 KB
/
Copy pathuninstall.sh
File metadata and controls
57 lines (51 loc) · 1.56 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
#!/bin/bash
INSTALL_DIR="$HOME/.swapinette"
COMMAND_NAME="swapinette"
# Couleurs
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
read -n1 -r -p "[!] Are you sure you want to uninstall Swapinette? [y/n] " answer
echo
case "$answer" in
y|Y)
clear
echo -e "${RED}[ℹ] Uninstalling Swapinette...${NC}"
sleep 0.2
cd "$HOME" || exit 1
if [ -d "$INSTALL_DIR" ]; then
chmod -R u+w "$INSTALL_DIR" 2>/dev/null
rm -rf "$INSTALL_DIR"
if [ -d "$INSTALL_DIR" ]; then
sleep 0.2
echo -e "${RED}[⚠] Could not fully remove $INSTALL_DIR${NC}"
else
sleep 0.2
echo -e "${GREEN}[✔] Removed $INSTALL_DIR${NC}"
fi
else
sleep 0.2
echo -e "${YELLOW}[ℹ] No installation directory found${NC}"
fi
SHELL_CONFIG=""
shell_name=$(basename "$SHELL")
case "$shell_name" in
zsh) SHELL_CONFIG="$HOME/.zshrc" ;;
bash) SHELL_CONFIG="$HOME/.bashrc" ;;
*) SHELL_CONFIG="$HOME/.profile" ;;
esac
if [ -f "$SHELL_CONFIG" ]; then
sed -i.bak "/alias $COMMAND_NAME=/d" "$SHELL_CONFIG"
sleep 0.2
echo -e "${GREEN}[✔] Alias removed from $SHELL_CONFIG${NC} (backup saved as $SHELL_CONFIG.bak)"
fi
echo -e "${GREEN}[✔] Swapinette has been successfully uninstalled!${NC}"
sleep 0.2
exit 42
;;
*)
exit 0
;;
esac