# Run this to install and update all the dotfiles in $HOME/dotfiles # Set function via http://stackoverflow.com/a/8574392/135978 # Also works in bash 3.2 so you can install on a Mac # Duplicated here so the installation file can be run stand-alone containsElement() { set +x local e for e in "${@:2}"; do [[ "$e" == "$1" ]] && set -x && return 0; done set -x return 1 } set -x export CONFIGDIR="${CONFIGDIR:-$HOME/dotfiles}"; LOCAL_BIN=${LOCAL_BIN:-~/.local/bin} if [ ! -d $CONFIGDIR ]; then git clone https://github.com/svieira/dotfiles $CONFIGDIR else pushd $CONFIGDIR git pull origin master popd fi while : ; do command -v brew >/dev/null 2>&1 && break || { echo >&2 "brew is not currently installed, please install it" read -p "Continue? [Y/n]" answer [[ "$answer" =~ "[nNqQ]" ]] && exit 1; } done # Install brew-managed programs brew bundle install --file $CONFIGDIR/Brewfile _brew_prefix="$(brew --prefix)" for f in bashrc profile inputrc vimrc psqlrc do [ -f ~/.$f -a ! -L ~/.$f ] && mv ~/.$f ~/.$f.old [ -L ~/.$f ] && continue ln -s $CONFIGDIR/$f ~/.$f done # Local machine setup # Ensure that we're using latest bash as our login shell if grep -i $_brew_prefix/bin/bash /etc/shells > /dev/null; then echo "Homebrew-managed bash already in /etc/shells" else echo "$_brew_prefix/bin/bash" | sudo tee -a /etc/shells > /dev/null chsh -s $_brew_prefix/bin/bash fi if (( BASH_VERSINFO < 4 )); then echo "Descending into subshell using homebrewed bash" $_brew_prefix/bin/bash -l "$0" fi . ~/.profile mkdir -p $HOME/.local mkdir -p $LOCAL_BIN mkdir -p $HOME/.local/opt mkdir -p $HOME/.local/opt/cdpath # For vim files: see vimrc mkdir -p $HOME/.vim/backups mkdir -p $HOME/.vim/swaps mkdir -p $HOME/.vim/undo # Link all bin files for program in $CONFIGDIR/bin/*; do program=${program##*/} [[ -f $LOCAL_BIN/$program ]] && continue ln -s $CONFIGDIR/bin/$program $LOCAL_BIN/$program done # Improve Mac Dictionary # Still need to update Dictionary.app preferences manually # Go to Preferences of Dictionary.app, select Webster's Unabridged Dictionary and drag it to the top. git clone https://github.com/altosaar/webster-mac.git cp -r webster-mac/Webster\'s\ Unabridged\ Dictionary.dictionary /Users/`whoami`/Library/Dictionaries/ rm -rf webster-mac set +x echo "Installation complete"