-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·79 lines (69 loc) · 2.21 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Step 1: download tools
install_zsh_users_plugins() {
echo "installing $1"
git clone https://github.com/zsh-users/$1.git ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/$1
}
if [[ -z "${ZSH}" && ! -e ${HOME}/.oh-my-zsh ]]
then
echo "installing Oh-My-ZSH"
ZSH=${HOME}/.oh-my-zsh sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh); exit"
install_zsh_users_plugins zsh-autosuggestions
install_zsh_users_plugins zsh-syntax-highlighting
else
echo "Oh-My-ZSH was already installed, skipping"
fi
if [[ ! -d "${HOME}/.tmux" ]]
then
echo "Downloading tmux configs from github"
git clone https://github.com/ruihangdu/.tmux.git ${HOME}/.tmux
else
while true; do
read -p "${HOME}/.tmux directory already exists. Do you wish to overwrite it?" yn
case $yn in
[Yy]* ) rm -rf ${HOME}/.tmux && git clone https://github.com/ruihangdu/.tmux.git ${HOME}/.tmux; break;;
[Nn]* ) echo "Skipping .tmux setup"; break;;
* ) echo "Please answer [Yy]/[Nn]";;
esac
done
fi
if [ ! -L "${HOME}/.tmux.conf" ]
then
ln -s ${HOME}/.tmux/.tmux.conf ${HOME}/.tmux.conf
fi
# Step 2: Install packages
install_package_if_not_installed() {
if ! type $1 > /dev/null 2>&1; then
echo "installing $1"
sudo apt install $1
else
echo "Package $1 already installed."
fi
}
install_convenience_packages() {
install_package_if_not_installed stow
install_package_if_not_installed bat
if [ ! -d "{HOME}/.local/bin" ]; then
mkdir -p ${HOME}/.local/bin
ln -s /usr/bin/batcat ${HOME}/.local/bin/bat
fi
}
while true; do
read -p "Do you have sudo access to this machine?" yn
case $yn in
[Yy]* ) install_convenience_packages; break;;
[Nn]* ) echo "Skipping installing convenience packages"; break;;
* ) echo "Please answer [Yy]/[Nn]";;
esac
done
# Step 3: Clean up previous dotfiles
dotfiles=("${HOME}/.zshrc" "${HOME}/.zsh_functions" "${HOME}/.vimrc" "${HOME}/.vim")
for dotfile in "${dotfiles[@]}"
do
if [ -e ${dotfile} ]
then
rm -rfv ${dotfile}
fi
done
# Step 4: Unpack dotfiles to home dir
stow -t ${HOME} vim zsh