-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·63 lines (45 loc) · 1.2 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
#!/bin/bash
set -e
SH_RC_FILE="$HOME/.bashrc"
GSF="git-switch-fzf"
SHARE_DIR="$HOME/.local/share/"
BIN_DIR="$HOME/.local/bin/"
msg() {
echo "[$GSF/install.sh]: $1"
}
if [ -f "$HOME/.zshrc" ]; then
SH_RC_FILE="$HOME/.zshrc"
fi
if [ ! -e "$SH_RC_FILE" ]; then
msg "error: cannot get shell rc file"
else
msg "shell rc file is $SH_RC_FILE"
fi
if ! [ -d "$SHARE_DIR" ]; then
msg "create dir $SHARE_DIR"
mkdir -p "$SHARE_DIR"
fi
if [ -d "$SHARE_DIR$GSF" ]; then
msg "remove old $GSF repo"
rm -rfI "$SHARE_DIR$GSF"
fi
msg "clone repo"
git clone --depth=1 https://github.com/emgyrz/git-switch-fzf "$SHARE_DIR$GSF"
if ! [ -d "$BIN_DIR" ]; then
msg "create $BIN_DIR"
mkdir -p "$BIN_DIR"
fi
msg "create symbolic link to $SHARE_DIR$GSF/$GSF script in $BIN_DIR"
rm -rfI "$BIN_DIR$GSF"
ln -s "$SHARE_DIR$GSF/$GSF" "$BIN_DIR$GSF"
if ! [[ $PATH == *"$BIN_DIR"* ]]; then
msg "add $BIN_DIR to \$PATH variable"
echo "export PATH=\$PATH:$BIN_DIR" >> "$SH_RC_FILE"
if [[ $SH_RC_FILE == *".bashrc" ]]; then
msg "update current env"
. $SH_RC_FILE
else
msg "WARNING! dont forget to update your current env if you want to use $GSF immediately, e.g. 'source ~/.zshrc'"
fi
fi
msg "done"