install.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. FILES="
  24. .profile
  25. .vimrc
  26. .eslintrc.js
  27. .irbrc
  28. "
  29. for FILE in $FILES; do
  30. link "$CMD_DIR/$FILE" "$HOME/"
  31. done
  32. # extra links for .profile
  33. link "$CMD_DIR/.profile" "$HOME/.zshrc"
  34. link "$CMD_DIR/.profile" "$HOME/.bashrc"
  35. link "$CMD_DIR/.profile" "$HOME/.bash_profile" # certain scenarios use this one
  36. OS=$(uname -s)
  37. if [ "$OS" = "Darwin" ]; then
  38. # Enable "All Controls" for tab in SystemPreferences->Keyboard->Shortcuts
  39. defaults write -globalDomain AppleKeyboardUIMode -int 3
  40. # Setup things for SystemPreferences->Keyboard->Shortcuts->App Shortcuts
  41. defaults write -globalDomain NSUserKeyEquivalents -dict \
  42. '\033Window\033Zoom' '@~^m' \
  43. '\033Window\033Move Window to Left Side of Screen' '@~^\U2190' \
  44. '\033Window\033Move Window to Right Side of Screen' '@~^\U2192' \
  45. '\033Window\033Tile Window to Left of Screen' '@~^$\U2190' \
  46. '\033Window\033Tile Window to Right of Screen' '@~^$\U2192'
  47. fi