install.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. .irbrc
  27. "
  28. for FILE in $FILES; do
  29. link "$CMD_DIR/$FILE" "$HOME/"
  30. done
  31. # extra links for .profile
  32. link "$CMD_DIR/.profile" "$HOME/.zshrc"
  33. link "$CMD_DIR/.profile" "$HOME/.bashrc"
  34. link "$CMD_DIR/.profile" "$HOME/.bash_profile" # certain scenarios use this one
  35. OS=$(uname -s)
  36. if [ "$OS" = "Darwin" ]; then
  37. # Enable "All Controls" for tab in: System Settings > Keyboard > Keyboard navigation
  38. defaults write -globalDomain AppleKeyboardUIMode -int 3
  39. # Setup things for: System Settings > Keyboard > Keyboard Shortcuts > App Shortcuts
  40. Sep="\033" KCmd='@' KOpt='~' KCtrl='^' KShift='$' KLeft='\U2190' KRight='\U2192'
  41. defaults write -globalDomain NSUserKeyEquivalents -dict-add \
  42. "${Sep}Window${Sep}Zoom" "${KCmd}${KOpt}${KCtrl}m" \
  43. "${Sep}Window${Sep}Move Window to Left Side of Screen" "${KCmd}${KOpt}${KCtrl}${KLeft}" \
  44. "${Sep}Window${Sep}Move Window to Right Side of Screen" "${KCmd}${KOpt}${KCtrl}${KRight}" \
  45. "${Sep}Window${Sep}Tile Window to Left of Screen" "${KCmd}${KOpt}${KCtrl}${KShift}${KLeft}" \
  46. "${Sep}Window${Sep}Tile Window to Right of Screen" "${KCmd}${KOpt}${KCtrl}${KShift}${KRight}" \
  47. "${Sep}Window${Sep}Move Window Back to Mac" "${KCmd}${KOpt}${KCtrl}1"
  48. # Nudge the prefs daemon to reload things
  49. killall cfprefsd
  50. fi