-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·47 lines (39 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
set -e
export BASH_KIT_DIR=".kit"
export BASH_KIT_INSTALL="$HOME/$BASH_KIT_DIR"
if [ -d "$BASH_KIT_INSTALL" ]; then
echo "\033[0;31mBash Kit is already installed. Please remove $BASH_KIT_INSTALL if you want to re-install.\033[0m"
exit 1
fi
echo "\033[0;33mInstalling Bash Kit...\033[0m"
hash git &>/dev/null || {
echo "\033[0;31mgit not installed\033[0m"
}
git clone [email protected]:psynaptic/bash_kit.git "$BASH_KIT_INSTALL"
# Calculate the bash profile file location.
if [ -f "$HOME/.profile" ]; then
BASH_PROFILE=".profile"
elif [ -f "$HOME/.bash_profile" ]; then
BASH_PROFILE=".bash_profile"
elif [ -f "$HOME/.bashrc" ]; then
BASH_PROFILE=".bashrc"
fi
ZSH_PROFILE=".zshrc"
PROFILES="$BASH_PROFILE|$ZSH_PROFILE"
IFS='|'
for file in $(echo "$PROFILES"); do
cat << EOF >> $HOME/$file
# Import bash_kit for bash and zsh login shells.
export BASH_KIT_DIR="\$HOME/$BASH_KIT_DIR"
if [ -d "\$BASH_KIT_DIR" ]; then
if [ "\$BASH" -o "\$ZSH" ]; then
if [ -f "\$HOME/$BASH_KIT_DIR/profile" ]; then
. "\$HOME/$BASH_KIT_DIR/profile"
fi
fi
fi
EOF
done
unset IFS
echo "\033[0;35mTo complete the installation run the following command:\nsource $HOME/$BASH_PROFILE\033[0m"
echo "\033[0;32mDone\033[0m"