-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-bash.sh
executable file
·38 lines (30 loc) · 941 Bytes
/
setup-bash.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
#!/usr/bin/env bash
BASHRC_SOURCE=$(pwd)/bashrc
BASHRC_TARGET=~/.bashrc
BASHRC_LOCAL_SOURCE=$(pwd)/bashrc.local
BASHRC_LOCAL_TARGET=~/.bashrc.local
if [[ $1 != "--simple" ]]; then
# copy initial local .bashrc
cp $BASHRC_LOCAL_SOURCE $BASHRC_LOCAL_TARGET
# install bat
if ! command -v bat &>/dev/null && ! command -v batcat &>/dev/null; then
if [[ "$OSTYPE" == "linux"* ]]; then
sudo apt install -y bat
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install bat
fi
fi
# install nvm
export PROFILE=$BASHRC_LOCAL_TARGET
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
fi
# backup old bashrc
if [[ -f $BASHRC_TARGET && ! -L $BASHRC_TARGET ]]; then
mv $BASHRC_TARGET $BASHRC_TARGET.old
fi
# create local bashrc if not exists
touch $BASHRC_LOCAL_TARGET
# symlink bashrc
ln -sfn $BASHRC_SOURCE $BASHRC_TARGET
# load bashrc
source $BASHRC_TARGET