#!/usr/bin/env bash { # This ensures the entire script is downloaded. set -eo pipefail basedir="$HOME/go/src/github.com/tylerwince/dotfiles" repourl="git://github.com/tylerwince/dotfiles.git" function symlink() { src="$1" dest="$2" if [ -e "$dest" ]; then if [ -L "$dest" ]; then # Already symlinked -- I'll assume correctly. return else # Rename files with a ".bak" extension. echo "$dest already exists, renaming to $dest.bak" backup="$dest.bak" if [ -e "$backup" ]; then echo "Error: "$backup" already exists. Please delete or rename it." exit 1 fi mv -v "$dest" "$backup" fi fi ln -sf "$src" "$dest" } if [ ! -d $HOME/.oh-my-zsh ]; then echo "Setting up oh-my-zsh..." sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" fi if ! which git >/dev/null ; then echo "Error: git is not installed" exit 1 fi if [ -d "$basedir/.git" ]; then echo "Updating dotfiles using existing git..." cd "$basedir" git pull --quiet --rebase origin master || exit 1 else echo "Checking out dotfiles using git..." rm -rf "$basedir" git clone --quiet --depth=1 "$repourl" "$basedir" fi cd "$basedir" echo "Creating symlinks..." for path in .* ; do case "$path" in .|..|.git) continue ;; *) symlink "$basedir/$path" "$HOME/$path" ;; esac done if which tmux >/dev/null 2>&1 ; then echo "Setting up tmux..." tpm="$HOME/.tmux/plugins/tpm" if [ -e "$tpm" ]; then pushd "$tpm" >/dev/null git pull -q origin master popd >/dev/null else git clone -q https://github.com/tmux-plugins/tpm "$HOME/.tmux/plugins/tpm" fi $tpm/scripts/install_plugins.sh >/dev/null $tpm/scripts/clean_plugins.sh >/dev/null $tpm/scripts/update_plugin.sh >/dev/null else echo "Skipping tmux setup because tmux isn't installed." fi postinstall="$HOME/.postinstall" if [ -e "$postinstall" ]; then echo "Running post-install..." . "$postinstall" else echo "No post install script found. Optionally create one at $postinstall" fi echo "Done." } # This ensures the entire script is downloaded.