#!/usr/bin/env zsh
# Links this repo's zshrc into place, backing up what is already there.
# Usage: ./install.sh            (then run `plug-install` in a new shell)
emulate -L zsh
setopt err_return
ROOT=${0:A:h}
target=${ZDOTDIR:-$HOME}/.zshrc
if [[ -e $target || -L $target ]]; then
  backup=$target.backup.$(date +%Y%m%d-%H%M%S)
  mv $target $backup
  print "Backed up existing .zshrc to $backup"
fi
ln -s $ROOT/zshrc $target
print "Linked $target -> $ROOT/zshrc"
[[ -e $HOME/.zshenv ]] || { cp $ROOT/zshenv $HOME/.zshenv; print "Copied zshenv to ~/.zshenv" }
print "Open a new terminal, then run: plug-install"
