-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·61 lines (51 loc) · 1.64 KB
/
uninstall.sh
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
#!/bin/bash
# Check if pancake is installed
if ! command -v pancake &> /dev/null
then
echo "❌ pancake is not installed."
exit 0
fi
echo "🚀 Starting the uninstallation process..."
# Get the absolute path of pancake
PANCAKE_PATH=$(which pancake)
echo "🔍 Checking if pancake exists..."
# Check if pancake exists
if [ ! -f "$PANCAKE_PATH" ]; then
echo "❌ Error: pancake does not exist."
exit 1
fi
echo "✅ Found pancake."
echo "🔧 Removing pancake..."
# Remove pancake
rm "$PANCAKE_PATH"
echo "✅ pancake has been removed."
echo "📂 Removing pancake from the PATH..."
# Remove the directory of pancake from the PATH in the appropriate profile file
PROFILE_FILE=""
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
PROFILE_FILE=~/.bashrc
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
PROFILE_FILE=~/.zshrc
elif [[ "$OSTYPE" == "cygwin"* ]] || [[ "$OSTYPE" == "msys"* ]] || [[ "$OSTYPE" == "win32"* ]]; then
# Windows
PROFILE_FILE=~/.bash_profile
else
echo "❌ This OS is not supported."
exit 1
fi
# Use grep to check if the PATH update for pancake exists in the PROFILE_FILE
if grep -q "export PATH=\\$PATH:$(dirname "$PANCAKE_PATH")" "$PROFILE_FILE"; then
# If it exists, use sed to remove it
sed -i "" "/export PATH=\\\$PATH:$(dirname "$PANCAKE_PATH")/d" "$PROFILE_FILE"
fi
source "$PROFILE_FILE"
# Check if pancake is uninstalled
if ! command -v pancake &> /dev/null
then
echo "✅ pancake has been removed from the PATH and can no longer be accessed with the command 'pancake'."
echo "🎉 Uninstallation completed successfully!"
else
echo "❌ Failed to uninstall pancake."
fi