install.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. # setup nvim to use .vimrc
  36. NVIM_CFG_DIR="$HOME/config/nvim"
  37. if ! [ -f "$NVIM_CFG_DIR/init.vim" ]; then
  38. mkdir -p "$NVIM_CFG_DIR"
  39. echo "
  40. set runtimepath^=~/.vim runtimepath+=~/.vim/after
  41. let &packpath=&runtimepath
  42. source ~/.vimrc
  43. " > "$NVIM_CFG_DIR/init.vim"
  44. fi
  45. OS=$(uname -s)
  46. if [ "$OS" = "Darwin" ]; then
  47. # Enable "All Controls" for tab in: System Settings > Keyboard > Keyboard navigation
  48. defaults write -globalDomain AppleKeyboardUIMode -int 3
  49. # Setup things for: System Settings > Keyboard > Keyboard Shortcuts > App Shortcuts
  50. Sep="\033" KCmd='@' KOpt='~' KCtrl='^' KShift='$' KLeft='\U2190' KRight='\U2192'
  51. defaults write -globalDomain NSUserKeyEquivalents -dict-add \
  52. "${Sep}Window${Sep}Zoom" "${KCmd}${KOpt}${KCtrl}m" \
  53. "${Sep}Window${Sep}Move Window to Left Side of Screen" "${KCmd}${KOpt}${KCtrl}${KLeft}" \
  54. "${Sep}Window${Sep}Move Window to Right Side of Screen" "${KCmd}${KOpt}${KCtrl}${KRight}" \
  55. "${Sep}Window${Sep}Tile Window to Left of Screen" "${KCmd}${KOpt}${KCtrl}${KShift}${KLeft}" \
  56. "${Sep}Window${Sep}Tile Window to Right of Screen" "${KCmd}${KOpt}${KCtrl}${KShift}${KRight}" \
  57. "${Sep}Window${Sep}Move Window Back to Mac" "${KCmd}${KOpt}${KCtrl}1"
  58. # Nudge the prefs daemon to reload things
  59. killall cfprefsd
  60. fi