dotfiles/install.sh

61 lines
1.6 KiB
Bash
Raw Normal View History

2012-11-09 20:44:06 -08:00
#!/bin/bash
# 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
REPO_DIR="$( cd "$( dirname "$0" )" && pwd )"
2012-11-09 20:44:06 -08:00
# Remove a file if it exists then create a symlink to the one contained in ${REPO_DIR}
function linkFile() {
if [ -e $1 ]; then rm -rf $1; fi
ln -s ${REPO_DIR}/$1 $1;
}
# Create a directory named by first parameter. Delete directory first if it already exists.
function createDirectory() {
if [ -d $1 ]; then rm -rf $1; fi
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
# Perform the logic
2012-11-09 20:44:06 -08:00
case "$choice" in
Y|y|yes )
echo "Moving to Home directory...";
cd ~;
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
echo "Linking shell configs...";
linkFile .bashrc
2012-11-09 20:44:06 -08:00
echo "Linking vim...";
linkFile .vimrc
createDirectory ~/.vim
createDirectory ~/.vim/swaps
createDirectory ~/.vim/backups
2012-11-09 20:44:06 -08:00
echo "Linking Git...";
linkFile .gitconfig
2012-11-09 20:44:06 -08:00
echo "Linking tmux...";
linkFile .tmux.conf
2012-11-20 11:13:43 -08:00
2013-04-25 07:31:07 -07:00
echo "Linking inputrc..."
linkFile .inputrc
echo "Done! Restart your shell to see changes"
2012-11-09 20:44:06 -08:00
;;
* ) echo "Aborted!";;
esac