#! /bin/bash
set -eou pipefail
mkdir -p $HOME/.ssh
for link in bashrc gitconfig screenrc Xresources Xdefaults Xmodmap themes fonts 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/.$link ]; then
	ln -s $(pwd)/sshconfig $HOME/.ssh/config;
fi

cat $(pwd)/pubkeys/* > $HOME/.ssh/authorized_keys
