#! /bin/bash
set -eou pipefail
mkdir -p $HOME/.ssh
cat $(pwd)/pubkeys/* > $HOME/.ssh/authorized_keys
for link in bashrc gitconfig screenrc Xresources Xdefaults Xmodmap  aliases vim vimrc hushlogin ;do
	#remove real files if present, making room for links
	if [ -f $HOME/.$link ]; then
		#echo 'removing' $HOME/.$link;
		rm $HOME/.$link;
	fi
	if [ ! -e $HOME/.$link ]; then
		#echo 'linking ' $(pwd)/$link $HOME/.$link;
		ln -s $(pwd)/$link $HOME/.$link;
	fi

done
if [ ! -e  $HOME/.ssh/config ]; then
	ln -s $(pwd)/sshconfig $HOME/.ssh/config;
fi
if [ ! -e  $HOME/.vim/bundle/Vundle.vim ]; then
  git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
  vim -E -c VundleInstall -c q
fi

