-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
64 lines (52 loc) · 1.74 KB
/
install.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
62
63
64
#!/bin/bash
# Variables
INSTALL_DIR="$HOME/.local/bin"
PROJECT_NAME="Simple-Quick-Squash"
PROJECT_DIR="$INSTALL_DIR/$PROJECT_NAME"
SCRIPT_NAME="quick-squash.sh"
LINK_NAME="quick-squash"
# Function to display usage
function usage() {
echo "Usage: ./install.sh"
}
# Create the install directory if it doesn't exist
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating installation directory at $INSTALL_DIR..."
mkdir -p "$INSTALL_DIR"
fi
# Move the project folder into INSTALL_DIR
if [ -d "$PROJECT_DIR" ]; then
echo "Project already exists in $INSTALL_DIR. Updating..."
rm -rf "$PROJECT_DIR"
fi
echo "Copying project to $INSTALL_DIR..."
cp -r "$(pwd)" "$PROJECT_DIR"
# Make quick-squash.sh executable
echo "Making $PROJECT_DIR/$SCRIPT_NAME executable..."
chmod +x "$PROJECT_DIR/$SCRIPT_NAME"
# Check if INSTALL_DIR is in the PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo "Adding $INSTALL_DIR to your PATH..."
SHELL_NAME=$(basename "$SHELL")
case "$SHELL_NAME" in
bash)
PROFILE_FILE="$HOME/.bashrc"
;;
zsh)
PROFILE_FILE="$HOME/.zshrc"
;;
fish)
PROFILE_FILE="$HOME/.config/fish/config.fish"
;;
*)
PROFILE_FILE="$HOME/.profile"
;;
esac
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$PROFILE_FILE"
echo "Updated PATH in $PROFILE_FILE."
echo "Please restart your terminal or source your profile with: source $PROFILE_FILE"
fi
# Create a symlink quick-squash -> ./quick-squash.sh
echo "Creating symlink $INSTALL_DIR/$LINK_NAME -> $PROJECT_DIR/$SCRIPT_NAME..."
ln -sf "$PROJECT_DIR/$SCRIPT_NAME" "$INSTALL_DIR/$LINK_NAME"
echo "Installation complete! You can now use the 'quick-squash' command."