.dotfiles/setup.sh

87 lines
1.5 KiB
Bash
Raw Normal View History

2020-11-07 14:03:30 +01:00
#!/bin/bash
2020-11-07 15:58:15 +01:00
cd "$(dirname "$0")"
2020-11-07 14:03:30 +01:00
function isInstalled(){
if [ "$(which $1)" != "" ]; then
return 0;
fi
return 1;
}
function installOptional(){
echo "install optional '$*'"
# Check if any of the listed programs are installed
# if not install the first one;
for prog in "$@"
do
if isInstalled $prog; then
echo "$prog is installed";
break
fi
done
install $1;
}
function install {
# Check if program is already installed
if isInstalled $1; then
2020-11-07 15:58:15 +01:00
echo " - $1 is already installed"
2020-11-07 14:03:30 +01:00
else
2020-11-07 15:58:15 +01:00
echo " - installing $1 ..."
apt-get install $1 -y > /dev/null
echo " - finished"
2020-11-07 14:03:30 +01:00
fi
}
2020-11-07 15:58:15 +01:00
function linkFile {
#Move old file
if [ -f "$HOME/$1" ]; then
echo " - moving old file to $1_bak"
mv "$HOME/$1" "$HOME/$1_bak"
fi
#Link $1
echo " - linking $(pwd)/$1 --> $HOME/$1"
ln -s "$(pwd)/$1" "$HOME/$1"
}
2020-11-07 14:03:30 +01:00
#Prerequesits
echo "-- Installing prerequisites --"
install git
install curl
install neovim
2020-11-07 14:03:30 +01:00
2020-11-07 15:58:15 +01:00
echo "-- Linking .dotfiles --"
linkFile .bashrc
linkFile .zshrc
linkFile .p10k.zsh
linkFile .gitconfig
linkFile .dircolors
linkFile .gitconfig-coco
2020-11-07 14:03:30 +01:00
echo "-- Installing Oh-My-Zsh --"
install zsh
2020-11-07 15:58:15 +01:00
sh $(pwd)/install/oh-my-zsh.sh
sh $(pwd)/install/zsh-autosuggestions.sh
zsh $(pwd)/install/p10k.sh
install direnv
echo "-- Configuring Optixal's Neovim (https://github.com/Optixal/neovim-init.vim) --"
sh $(pwd)/nvim/install-config.sh
2020-11-07 15:58:15 +01:00
echo "-- Applying .zshrc --"
if [ $SHELL != $(which zsh) ]; then
echo "- changing default shell"
chsh -s $(which zsh)
export SHELL=$(which zsh)
fi
zsh
cd