install.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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" "$HOME/.eslintrc"
  25. link "$CMD_DIR/.jshintrc" "$HOME/.jshintrc"
  26. link "$CMD_DIR/.jscsrc" "$HOME/.jscsrc"
  27. link "$CMD_DIR/.node-inspectorrc" "$HOME/.node-inspectorrc"
  28. mkdir -p "$HOME/.atom"
  29. for F in "$CMD_DIR/atom/"*; do
  30. FN=${F##*/}
  31. link "$CMD_DIR/atom/$FN" "$HOME/.atom/$FN"
  32. done
  33. if ! [[ -d "$HOME/.atom/packages/" ]]; then
  34. if which apm &>/dev/null; then
  35. "$CMD_DIR/install_atom_plugins.sh"
  36. else
  37. echo "# WARN: Unable to find Atom's \"apm\" command."
  38. echo "# WARN: 1. Get Atom from the website or automatically using \"gimme atom\""
  39. echo "# WARN: 2. Install the atom plugins using \"$CMD_DIR/install_atom_plugins.sh\""
  40. fi
  41. fi