install.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: System Settings > Keyboard > Keyboard navigation
  39. defaults write -globalDomain AppleKeyboardUIMode -int 3
  40. # Setup things for: System Settings > Keyboard > Keyboard Shortcuts > App Shortcuts
  41. Sep="\033" KCmd='@' KOpt='~' KCtrl='^' KShift='$' KLeft='\U2190' KRight='\U2192'
  42. defaults write -globalDomain NSUserKeyEquivalents -dict-add \
  43. "${Sep}Window${Sep}Zoom" "${KCmd}${KOpt}${KCtrl}m" \
  44. "${Sep}Window${Sep}Move Window to Left Side of Screen" "${KCmd}${KOpt}${KCtrl}${KLeft}" \
  45. "${Sep}Window${Sep}Move Window to Right Side of Screen" "${KCmd}${KOpt}${KCtrl}${KRight}" \
  46. "${Sep}Window${Sep}Tile Window to Left of Screen" "${KCmd}${KOpt}${KCtrl}${KShift}${KLeft}" \
  47. "${Sep}Window${Sep}Tile Window to Right of Screen" "${KCmd}${KOpt}${KCtrl}${KShift}${KRight}" \
  48. "${Sep}Window${Sep}Move Window Back to Mac" "${KCmd}${KOpt}${KCtrl}1"
  49. # Nudge the prefs daemon to reload things
  50. killall cfprefsd
  51. fi