#!/usr/bin/env bash set -x if [ $? -ne 0 ]; then echo "please run the script again with a correct password" exit 1 fi ALL=true SKIP_RUBY=false while [[ $# -gt 0 ]] do key="$1" case $key in --system) SYSTEM=true ALL=false shift # past argument ;; --gui) GUI=true ALL=false shift # past argument ;; --skip-ruby) SKIP_RUBY=true shift # past argument ;; *) # unknown option EMAIL="$1" shift # past argument ;; esac done if [ -z "$EMAIL" ]; then echo "please provide an email address as an argument" exit 1 fi cd $HOME git clone https://github.com/doodzik/dotfiles # ============================================== # homebrew # ============================================== if [ "$ALL" == true ] ; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" if [ "$(arch)" = "arm64" ]; then eval $(/opt/homebrew/bin/brew shellenv); else eval $(/usr/local/bin/brew shellenv); fi brew tap doodzik/tap brew tap homebrew/dupes # for screen brew tap homebrew/cask cmds=( bash_join fastlane fzf git git-lfs m-cli note npm-scripts nvm the_silver_searcher tidy-html5 yarn youtube-dl zsh ) if [ "$SKIP_RUBY" == false ] ; then # install ruby brew install rbenv LATEST_RUBY=$(rbenv install -l | sed -n '/^[[:space:]]*[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}[[:space:]]*$/ h;${g;p;}') rbenv install $LATEST_RUBY rbenv rehash rbenv global $LATEST_RUBY fi brew install vim brew install ${cmds[@]} || { echo 'brew failed' ; exit 1; } fi # ============================================== # github # ============================================== if [ "$ALL" == true ] ; then ln -s ~/dotfiles/.githooks $HOME/.githooks ln -s ~/dotfiles/.gitaliases $HOME/.gitaliases ln -s ~/dotfiles/.gitmessage $HOME/.gitmessage ln -s ~/dotfiles/.gitignore_osx $HOME/.gitignore_osx ln -s ~/dotfiles/.vimrc $HOME/.vimrc ln -s ~/dotfiles/.vim $HOME/.vim ln -s ~/dotfiles/.screenrc $HOME/.screenrc git config --global user.name "Frederik Dudzik" git config --global user.email "$EMAIL" git config --global push.default simple git config --global core.editor vim git config --global credential.helper osxkeychain git config --global core.excludesfile ~/.gitignore_osx git config --global include.path ~/.gitaliases git config --global commit.template ~/.gitmessage git config --global core.hooksPath ~/.githooks git config --global push.default current ssh-keygen -t rsa -b 4096 -C "$EMAIL" eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub | pbcopy # echo in red tput setaf 1 echo 'copied key to clipboard. opening github settings.' # stop echoing in red tput sgr0 echo 'Press [Enter] key when added key to github' sleep 2 open https://github.com/settings/ssh read -p '' # setup repo for dotfiles cd ~/dotfiles git submodule update --init --recursive --remote cd .zprezto git submodule update --init --recursive --remote echo "GitHub: When you are asked for your username and password. Enter your username, then in the password prompt paste your Personal Access Token from your password manager." cd .. cd .vim ./install cd fi # ============================================== # nvm # ============================================== if [ "$ALL" == true ] ; then # setup node mkdir ~/.nvm . $(brew --prefix nvm)/nvm.sh nvm install node nvm alias default node nvm use node fi # ============================================== # Xcode # ============================================== if [ "$ALL" == true ] ; then echo "Setting Xcode preferences" # Always use spaces for indenting defaults write com.apple.dt.Xcode DVTTextIndentUsingTabs -bool false # Show tab bar defaults write com.apple.dt.Xcode AlwaysShowTabBar -bool true sudo gem install cocoapods fi # ============================================= # GUI # ============================================= if [[ "$ALL" == true ]] || [[ "$GUI" == true ]]; then echo "installing gui..." guis=( vlc iterm2 monitorcontrol ) brew install --cask ${guis[@]} echo 'setup icloud && opening apps' echo 'trackpad tap to click & look up with 3 fingers' echo 'spaces: disable Automatically rearrange Spaces based on most recent use' echo 'Press [Enter] if done' sleep 2 open -a System\ Preferences osascript -e ' on run do shell script "echo setup assistive access for the terminal" end run' read -p '' fi # ============================================== # system # ============================================== # monitor changes to the settings # sudo opensnoop -n cfprefsd-int-int if [[ "$ALL" == true ]] || [[ "$SYSTEM" == true ]]; then # disable gateskeeper m gatekeeper disable # multitouch/trackpad defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerTapGesture -int 2; defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -int 1; defaults write -g com.apple.trackpad.scaling 3 # keyboard defaults write com.apple.HIToolbox AppleEnabledInputSources -array-add '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 0; "KeyboardLayout Name" = "U.S"; }' defaults write InitialKeyRepeat -int 15 defaults write KeyRepeat -int 2 # capslock to cntr # ~/Library/Preferences/ByHost/.GlobalPreferences mappingplist=com.apple.keyboard.modifiermapping.1452-585-0 defaults -currentHost write -g $mappingplist '({ HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; })' # menu bar defaults read com.apple.menuextra.battery ShowPercent -bool YES # users defaults write com.apple.loginwindow GuestEnabled -bool NO defaults write com.apple.loginwindow SHOWFULLNAME -int 1 # dock m dock autohide YES defaults write com.apple.dock mineffect -string 'scale' defaults write com.apple.dock persistent-apps '()' # finder m finder showhiddenfiles YES m finder showextensions YES # Don't offer new disks for backup defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true # symlink iCloud Folder to ~/ ln -s Library/Mobile\ Documents/com~apple~CloudDocs mv com\~apple\~CloudDocs iCloud # symbolic hotkeys # Select the previous input source - Command, Option, Space defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 60 "{ enabled = 1; value = { parameters = ( 32, 49, 262144 ); type = standard; }; }" # no blurry font defaults write com.apple.Terminal AppleFontSmoothing -int 0 RESTART=true fi # ============================================== # Zsh # ============================================== if [ "$ALL" == true ] ; then $HOME/dotfiles/.init_zsh fi # ============================================== # restart # ============================================== if [ "$RESTART" = true ] ; then echo 'Press [Enter] to restart the computer' read -p '' m restart fi