dotfiles/bootstrap.sh

60 lines
2.0 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2014-04-26 20:20:00 -06:00
cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh
2014-04-14 21:49:44 -06:00
DOTFILES_DIRECTORY="$(dotfiles_abspath)/dotfiles"
2014-05-02 02:26:54 -06:00
2014-05-02 14:36:04 -06:00
function make_powerline_symlinks() {
2014-05-02 02:26:54 -06:00
# Make a powerline link if powerline is installed
local powerline_location=$(pip show Powerline | grep Location | awk '{print $2}')
local conf_location="/powerline/bindings/tmux/powerline.conf"
local link_destination="$HOME/.tmux.powerline"
2014-05-02 14:36:04 -06:00
if test -z $powerline_location;
then
sudo pip install --user git+git://github.com/Lokaltog/powerline
fi
2014-05-02 02:26:54 -06:00
if test -z $powerline_location;
then
rm $link_destination 2> /dev/null
touch "$link_destination"
else
ln -si "$powerline_location$conf_location" $link_destination
fi
}
2013-09-25 17:38:16 -06:00
function symlink_dotfiles() {
2014-04-08 06:50:21 -06:00
cd $DOTFILES_DIRECTORY
2014-04-09 12:45:52 -06:00
[ -a ~/.dotfiles-backups ] && mv ~/.dotfiles-backups ~/.dotfiles-backups.old
2014-04-08 06:50:21 -06:00
mkdir ~/.dotfiles-backups
for filename in *; do
local link_destination="$HOME/.$filename"
2014-04-09 12:45:52 -06:00
local link_target=$(${readlink_command} -f $filename)
echo "linking $link_destination to $link_target"
# Using only test -e doesn't work here because it will return
2014-05-02 14:36:04 -06:00
# false if the destination of the symbolic link at does not exist.
2014-04-09 12:45:52 -06:00
test -e $link_destination || test -L $link_destination && mv $link_destination ~/.dotfiles-backups
ln -si $link_target $link_destination
2013-09-25 17:38:16 -06:00
done
2014-04-09 12:45:52 -06:00
[ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups
2014-05-02 14:36:04 -06:00
make_powerline_symlinks
2011-09-05 12:19:31 -06:00
}
function parse_options() {
while getopts "f" OPTCHAR; do
case $optchar in
f)
symlink_dotfiles
return
;;
esac
done
shift $((OPTIND-1))
2014-04-08 06:50:21 -06:00
read -p "Symlinking files from $DOTFILES_DIRECTORY. This may overwrite existing files in your home directory. Do you wish to proceed? (y/n) " -n 1
if [[ $REPLY =~ ^[Yy]$ ]]; then
symlink_dotfiles
fi
}
2014-04-08 06:50:21 -06:00
2014-04-14 21:49:44 -06:00
parse_options