#!/bin/bash

# Adrien Luxey - Feb. 2019
# Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh


# cd to this file's directory
DOTDIR=$(cd "$(dirname ${BASH_SOURCE})"; pwd)
# echo "DOTDIR: " $DOTDIR

function syncDotfiles() {
	rm $HOME/.zshrc > /dev/null 2>&1
	rm $HOME/.vimrc > /dev/null 2>&1
	rm $HOME/.tmux.conf > /dev/null 2>&1
	rm -rf $HOME/.vim > /dev/null 2>&1
	rm -rf $HOME/.tmux > /dev/null 2>&1
	rm -rf $HOME/.config/sublime-text-3/Packages/User > /dev/null 2>&1

	ln -s $DOTDIR/zshrc $HOME/.zshrc
	ln -s $DOTDIR/vimrc $HOME/.vimrc
	ln -s $DOTDIR/tmux.conf $HOME/.tmux.conf
	ln -s $DOTDIR/vim $HOME/.vim
	ln -s $DOTDIR/tmux $HOME/.tmux
	ln -s $DOTDIR/sublime $HOME/.config/sublime-text-3/Packages/User 
	
}
syncDotfiles

function installDependencies() {
	# Dependencies
	sudo apt update
	sudo apt install -y apt-transport-https curl zsh fonts-powerline

	# Install Sublime Text
	wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
	echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
	sudo apt update
	sudo apt install sublime-text -y

	# Install Oh My Zsh
	sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
	# Install powerlevel9k theme in Oh-My-Zsh
	git clone https://github.com/bhilburn/powerlevel9k.git $HOME/.oh-my-zsh/custom/themes/powerlevel9k
	
	# Set ZSH as default shell
	sudo -u $USER chsh -s $(which zsh)
}

