Repository navigation
Expand file tree
/
Copy pathinstall
More file actions
53 lines (44 loc) · 1.46 KB
/
Copy pathinstall
File metadata and controls
53 lines (44 loc) · 1.46 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
#!/usr/bin/env bash
set -e
echo Installing slotup...
BASE_DIR=${XDG_CONFIG_HOME:-$HOME}
SLOT_DIR=${SLOT_DIR-"$BASE_DIR/.slot"}
SLOT_BIN_DIR="$SLOT_DIR/bin"
SLOT_MAN_DIR="$SLOT_DIR/share/man/man1"
BIN_URL="https://raw.githubusercontent.com/cartridge-gg/slot/main/slotup/slotup"
BIN_PATH="$SLOT_BIN_DIR/slotup"
# Create the .slot bin directory and slotup binary if it doesn't exist.
mkdir -p $SLOT_BIN_DIR
curl -# -L $BIN_URL -o $BIN_PATH
chmod +x $BIN_PATH
# Create the man directory for future man files if it doesn't exist.
mkdir -p $SLOT_MAN_DIR
# Store the correct profile file (i.e. .profile for bash or .zshenv for ZSH).
case $SHELL in
*/zsh)
PROFILE=${ZDOTDIR-"$HOME"}/.zshenv
PREF_SHELL=zsh
;;
*/bash)
PROFILE=$HOME/.bashrc
PREF_SHELL=bash
;;
*/fish)
PROFILE=$HOME/.config/fish/config.fish
PREF_SHELL=fish
;;
*/ash)
PROFILE=$HOME/.profile
PREF_SHELL=ash
;;
*)
echo "slotup: could not detect shell, manually add ${SLOT_BIN_DIR} to your PATH."
exit 1
esac
# Only add slotup if it isn't already in PATH.
if [[ ":$PATH:" != *":${SLOT_BIN_DIR}:"* ]]; then
# Add the slotup directory to the path and ensure the old PATH variables remain.
echo >> $PROFILE && echo "export PATH=\"\$PATH:$SLOT_BIN_DIR\"" >> $PROFILE
fi
echo && echo "Detected your preferred shell is ${PREF_SHELL} and added slotup to PATH. Run 'source ${PROFILE}' or start a new terminal session to use slotup."
echo "Then, simply run 'slotup' to install Slot."