install.sh 1.3 KB

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