-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwizard.sh
executable file
·47 lines (43 loc) · 1.44 KB
/
wizard.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
#!/bin/bash
PROGRAM_NAME="impzy"
BINARY_FILE="./impzy"
INSTALL_DIR="$HOME/.local/share/$PROGRAM_NAME"
install_program() {
# Create the installation directory if it doesn't exist
if [ ! -d "$INSTALL_DIR" ]; then
mkdir -p "$INSTALL_DIR"
fi
# Copy the binary file to the installation directory
cp "$BINARY_FILE" "$INSTALL_DIR/$PROGRAM_NAME"
# Add the path to PATH in .zshrc if it's not already added
if ! grep -q "export PATH=\"$INSTALL_DIR:\$PATH\"" "$HOME/.zshrc"; then
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$HOME/.zshrc"
echo "Added $INSTALL_DIR to PATH in .zshrc"
else
echo "Path '$INSTALL_DIR' is already in PATH"
fi
echo "Program '$PROGRAM_NAME' has been installed in '$INSTALL_DIR'"
}
uninstall_program() {
# Remove the installation directory
if [ -d "$INSTALL_DIR" ]; then
rm -rf "$INSTALL_DIR"
fi
# Remove the PATH line in .zshrc if it exists
if grep -q "export PATH=\"$INSTALL_DIR:\$PATH\"" "$HOME/.zshrc"; then
# sed -i "/export PATH=\"$INSTALL_DIR:\$PATH\"/d" "$HOME/.zshrc"
sed -i "\#export PATH=\"$INSTALL_DIR:\$PATH\"#d" "$HOME/.zshrc"
echo "Removed $INSTALL_DIR from PATH in .zshrc"
else
echo "Path '$INSTALL_DIR' is not in PATH"
fi
echo "Program '$PROGRAM_NAME' has been uninstalled"
}
# Check the argument passed to the script
if [ "$1" == "install" ]; then
install_program
elif [ "$1" == "uninstall" ]; then
uninstall_program
else
echo "Usage: $0 {install|uninstall}"
fi