.dotfiles/setup.sh
2020-11-07 15:58:15 +01:00

76 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
cd "$(dirname "$0")"
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
echo " - $1 is already installed"
else
echo " - installing $1 ..."
apt-get install $1 -y > /dev/null
echo " - finished"
fi
}
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"
}
#Prerequesits
echo "-- Installing prerequisites --"
install git
install curl
echo "-- Linking .dotfiles --"
linkFile .bashrc
linkFile .zshrc
linkFile .p10k.zsh
linkFile .gitconfig
linkFile .dircolors
linkFile .gitconfig-coco
echo "-- Installing Oh-My-Zsh --"
install zsh
sh $(pwd)/install/oh-my-zsh.sh
sh $(pwd)/install/zsh-autosuggestions.sh
zsh $(pwd)/install/p10k.sh
install direnv
echo "-- Applying .zshrc --"
chsh -s $(which zsh)
export SHELL=$(which zsh)
zsh