install.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. set -o errexit -o pipefail
  3. # support piping directly into curl
  4. if [[ "$ZSH_VERSION" ]]; then
  5. setopt posixargzero
  6. fi
  7. if [[ "$0" =~ -?(z|ba)sh && ! "${BASH_SOURCE[*]}" ]]; then
  8. git clone "https://github.com/KylePDavis/dotfiles" "$HOME/.dotfiles"
  9. exec "$HOME/.dotfiles/install.sh"
  10. fi
  11. CMD_DIR=$(cd "${BASH_SOURCE%/*}"; echo "$PWD")
  12. link() {
  13. local SRC=$1
  14. local DST=$2
  15. if ! [[ -L "$DST" ]]; then
  16. if [[ -f "$DST" ]]; then
  17. mv -vi "$DST" "$DST.bak"
  18. fi
  19. mkdir -p "${DST%/*}"
  20. ln -sfv "$SRC" "$DST"
  21. fi
  22. }
  23. link "$CMD_DIR/.profile" "$HOME/.profile"
  24. link "$CMD_DIR/.profile" "$HOME/.zshrc"
  25. link "$CMD_DIR/.profile" "$HOME/.bashrc"
  26. link "$CMD_DIR/.profile" "$HOME/.bash_profile" # certain scenarios use this one
  27. link "$CMD_DIR/.vimrc" "$HOME/.vimrc"
  28. link "$CMD_DIR/.eslintrc.js" "$HOME/.eslintrc.js"
  29. mkdir -p "$HOME/.atom"
  30. for F in "$CMD_DIR/atom/"*; do
  31. FN=${F##*/}
  32. link "$CMD_DIR/atom/$FN" "$HOME/.atom/$FN"
  33. done
  34. if ! [[ -d "$HOME/.atom/packages/" ]]; then
  35. if which apm &>/dev/null; then
  36. echo "# INFO: If you use Atom then you may want to run \"$CMD_DIR/install_atom_plugins.sh\""
  37. else
  38. echo "# WARN: Unable to find Atom's \"apm\" command."
  39. echo "# WARN: 1. Get Atom from the website or automatically using \"gimme atom\""
  40. echo "# WARN: 2. Install the atom plugins using \"$CMD_DIR/install_atom_plugins.sh\""
  41. fi
  42. fi
  43. OS=$(uname -s)
  44. if [ "$OS" = "Darwin" ]; then
  45. # Enable "All Controls" for tab in SystemPreferences->Keyboard->Shortcuts
  46. defaults write -globalDomain AppleKeyboardUIMode -int 3
  47. # Setup things for SystemPreferences->Keyboard->Shortcuts->App Shortcuts
  48. defaults write -globalDomain NSUserKeyEquivalents -dict \
  49. '\033Window\033Zoom' '@~^m' \
  50. '\033Window\033Move Window to Left Side of Screen' '@~^\U2190' \
  51. '\033Window\033Move Window to Right Side of Screen' '@~^\U2192' \
  52. '\033Window\033Tile Window to Left of Screen' '@~^$\U2190' \
  53. '\033Window\033Tile Window to Right of Screen' '@~^$\U2192'
  54. fi