2012-11-09 20:44:06 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-01-03 13:37:43 -08:00
|
|
|
# Make sure git is installed. Exit if it isn't
|
|
|
|
if which git; then
|
|
|
|
echo "Please install git before continuing"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-11-09 20:44:06 -08:00
|
|
|
|
2014-01-03 13:37:43 -08:00
|
|
|
REPO_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
2012-11-09 20:44:06 -08:00
|
|
|
|
2014-01-03 13:37:43 -08:00
|
|
|
# Remove a file if it exists then create a symlink to the one contained in ${REPO_DIR}
|
2013-03-21 20:56:52 -07:00
|
|
|
function linkFile() {
|
2014-01-03 13:37:43 -08:00
|
|
|
if [ -e $1 ]; then rm -rf $1; fi
|
|
|
|
ln -s ${REPO_DIR}/$1 $1;
|
2013-03-21 20:56:52 -07:00
|
|
|
}
|
|
|
|
|
2014-01-03 13:37:43 -08:00
|
|
|
# Create a directory named by first parameter. Delete directory first if it already exists.
|
2013-03-21 20:56:52 -07:00
|
|
|
function createDirectory() {
|
2014-01-03 13:37:43 -08:00
|
|
|
if [ -d $1 ]; then rm -rf $1; fi
|
2013-03-21 20:56:52 -07:00
|
|
|
mkdir $1
|
|
|
|
}
|
|
|
|
|
2013-03-21 21:30:06 -07:00
|
|
|
echo "This will create symlinks and destroy any conflicting configs already in place.";
|
|
|
|
read -p "Continue? [y/N] " choice
|
|
|
|
|
2013-03-21 20:56:52 -07:00
|
|
|
# Perform the logic
|
2012-11-09 20:44:06 -08:00
|
|
|
case "$choice" in
|
|
|
|
Y|y|yes )
|
|
|
|
echo "Moving to Home directory...";
|
|
|
|
cd ~;
|
2014-01-03 13:37:43 -08:00
|
|
|
|
|
|
|
echo "Adding id_rsa.pub to authorized keys if necessary"
|
|
|
|
if [ ! -e ".ssh/authorized_keys" ] ; then
|
|
|
|
cp ${REPO_DIR}/.ssh/id_rsa.pub .ssh/authorized_keys
|
|
|
|
elif ! grep -q `cat ${REPO_DIR}/.ssh/id_rsa.pub` ".ssh/authorized_keys"; then
|
|
|
|
cat ${REPO_DIR}/.ssh/id_rsa.pub >> .ssh/authorized_keys
|
|
|
|
fi
|
2012-11-09 20:44:06 -08:00
|
|
|
|
2013-03-21 20:56:52 -07:00
|
|
|
echo "Linking shell configs...";
|
|
|
|
linkFile .bashrc
|
2013-03-04 20:59:34 -08:00
|
|
|
|
2012-11-09 20:44:06 -08:00
|
|
|
echo "Linking vim...";
|
2013-03-21 20:56:52 -07:00
|
|
|
linkFile .vimrc
|
|
|
|
createDirectory ~/.vim
|
|
|
|
createDirectory ~/.vim/swaps
|
|
|
|
createDirectory ~/.vim/backups
|
2012-11-09 20:44:06 -08:00
|
|
|
|
|
|
|
echo "Linking Git...";
|
2013-03-21 20:56:52 -07:00
|
|
|
linkFile .gitconfig
|
2012-11-09 20:44:06 -08:00
|
|
|
|
|
|
|
echo "Linking tmux...";
|
2013-03-21 20:56:52 -07:00
|
|
|
linkFile .tmux.conf
|
2012-11-20 11:13:43 -08:00
|
|
|
|
2013-04-25 07:31:07 -07:00
|
|
|
echo "Linking inputrc..."
|
|
|
|
linkFile .inputrc
|
|
|
|
|
2013-03-21 20:56:52 -07:00
|
|
|
echo "Done! Restart your shell to see changes"
|
2012-11-09 20:44:06 -08:00
|
|
|
;;
|
|
|
|
* ) echo "Aborted!";;
|
|
|
|
esac
|