install.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. set -o errexit -o pipefail
  3. # support curl|bash
  4. if [[ "$0" =~ [-]?bash ]] && ! [[ "$BASH_SOURCE" ]]; then
  5. git clone "https://github.com/KylePDavis/dotfiles" "$HOME/.dotfiles"
  6. exec "$HOME/.dotfiles/install.sh"
  7. fi
  8. CMD_DIR=$(cd "${BASH_SOURCE%/*}"; echo "$PWD")
  9. link() {
  10. local SRC=$1
  11. local DST=$2
  12. if ! [[ -L "$DST" ]]; then
  13. if [[ -f "$DST" ]]; then
  14. mv -vi "$DST" "$DST.bak"
  15. fi
  16. mkdir -p "${DST%/*}"
  17. ln -sfv "$SRC" "$DST"
  18. fi
  19. }
  20. link "$CMD_DIR/.profile" "$HOME/.profile" # Mac
  21. link "$CMD_DIR/.profile" "$HOME/.bashrc" # Linux
  22. link "$CMD_DIR/.profile" "$HOME/.bash_profile" # certain scenarios use this one
  23. link "$CMD_DIR/.vimrc" "$HOME/.vimrc"
  24. link "$CMD_DIR/.eslintrc.js" "$HOME/.eslintrc.js"
  25. link "$CMD_DIR/.node-inspectorrc" "$HOME/.node-inspectorrc"
  26. mkdir -p "$HOME/.atom"
  27. for F in "$CMD_DIR/atom/"*; do
  28. FN=${F##*/}
  29. link "$CMD_DIR/atom/$FN" "$HOME/.atom/$FN"
  30. done
  31. if ! [[ -d "$HOME/.atom/packages/" ]]; then
  32. if which apm &>/dev/null; then
  33. "$CMD_DIR/install_atom_plugins.sh"
  34. else
  35. echo "# WARN: Unable to find Atom's \"apm\" command."
  36. echo "# WARN: 1. Get Atom from the website or automatically using \"gimme atom\""
  37. echo "# WARN: 2. Install the atom plugins using \"$CMD_DIR/install_atom_plugins.sh\""
  38. fi
  39. fi