2011-09-05 12:19:31 -06:00
|
|
|
#!/bin/bash
|
2013-09-30 23:21:02 -06:00
|
|
|
case `uname` in
|
|
|
|
'Darwin')
|
|
|
|
readlink_command='greadlink'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
readlink_command='readlink'
|
|
|
|
esac
|
|
|
|
|
2013-11-22 11:52:22 -07:00
|
|
|
CURRENT_DIRECTORY="$(dirname "${BASH_SOURCE}" | xargs "${readlink_command}" -f)/dotfiles"
|
2013-09-25 17:38:16 -06:00
|
|
|
cd $CURRENT_DIRECTORY
|
|
|
|
|
|
|
|
echo "Linking From $CURRENT_DIRECTORY"
|
|
|
|
|
2013-11-22 11:52:22 -07:00
|
|
|
function symlink_dotfiles() {
|
2013-09-25 17:38:16 -06:00
|
|
|
[[ -a ~/.dotfiles-backups ]] || mkdir ~/.dotfiles-backups
|
2013-11-22 11:52:22 -07:00
|
|
|
for filename in *; do
|
|
|
|
local link_destination="$HOME/.$filename"
|
|
|
|
local absolute_path="$($readlink_command -f $filename)"
|
2014-04-08 05:08:57 -06:00
|
|
|
[[ -a $link_destination ]] && mv $link_destination ~/.dotfiles-backups
|
2013-11-22 11:52:22 -07:00
|
|
|
ln -si $absolute_path $link_destination
|
2013-09-25 17:38:16 -06:00
|
|
|
done
|
2011-09-05 12:19:31 -06:00
|
|
|
}
|
2013-03-31 20:16:52 -06:00
|
|
|
|
2011-09-05 12:19:31 -06:00
|
|
|
if [ "$1" == "--force" -o "$1" == "-f" ]; then
|
2013-03-17 16:46:42 -06:00
|
|
|
doIt
|
2011-09-05 12:19:31 -06:00
|
|
|
else
|
2013-03-17 16:46:42 -06:00
|
|
|
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
|
|
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
2013-11-22 11:52:22 -07:00
|
|
|
symlink_dotfiles
|
2013-03-17 16:46:42 -06:00
|
|
|
fi
|
2011-09-05 12:19:31 -06:00
|
|
|
fi
|
2013-11-22 11:52:22 -07:00
|
|
|
unset symlink_dotfiles
|