#!/usr/bin/env bash # # Bootstrap script for setting up a new OSX machine # # This should be idempotent so it can be run multiple times. # # Some apps don't have a cask and so still need to be installed by hand. These # include: # # - SVGSUS # - Divvy # # Notes: # # - If installing full Xcode, it's better to install that first from the app # store before running the bootstrap script. Otherwise, Homebrew can't access # the Xcode libraries as the agreement hasn't been accepted yet. # # Reading: # # - https://gist.github.com/MatthewMueller/e22d9840f9ea2fee4716 # - https://news.ycombinator.com/item?id=8402079 # - https://github.com/mathiasbynens/dotfiles/blob/master/.macos # - https://www.taniarascia.com/setting-up-a-brand-new-mac-for-development/ echo "Starting bootstrapping" # Close any open System Preferences panes, to prevent them from overriding # settings we’re about to change osascript -e 'tell application "System Preferences" to quit' # Ask for the administrator password upfront sudo -v # Keep-alive: update existing `sudo` time stamp until `.macos` has finished while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & xcode-select --install # Check for Homebrew, install if we don't have it if test ! $(which brew); then echo "Installing homebrew..." ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fi # Update homebrew recipes brew update # Install GNU core utilities (those that come with OS X are outdated) # brew tap homebrew/dupes # brew install coreutils # brew install gnu-sed --with-default-names # brew install gnu-tar --with-default-names # brew install gnu-indent --with-default-names # brew install gnu-which --with-default-names # brew install gnu-grep --with-default-names # Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed # brew install findutils # Install Bash 4 # brew install bash PACKAGES=( imagemagick markdown nano npm python python3 svgo tree yarn ) echo "Installing packages..." brew install ${PACKAGES[@]} echo "Installing cask..." brew tap homebrew/cask CASKS=( 1password abstract brave-browser cyberduck dropbox evernote firefox google-chrome imageoptim iterm2 ipvanish-vpn mamp microsoft-word microsoft-excel microsoft-outlook microsoft-powerpoint microsoft-teams miro mjml onedrive sketch slack spotify station steam visual-studio-code zoomus ) echo "Installing cask apps..." brew cask install ${CASKS[@]} echo "Installing fonts..." brew tap homebrew/cask-fonts # https://github.com/Homebrew/homebrew-cask-fonts/tree/master/Casks FONTS=( font-inconsolata font-roboto font-clear-sans font-inter font-exo font-noto-sans font-noto-serif font-noto-sans-display font-noto-serif-display ) brew cask install ${FONTS[@]} echo "Cleaning up..." brew cleanup # echo "Installing Python packages..." # PYTHON_PACKAGES=( # ipython # virtualenv # virtualenvwrapper # ) # sudo pip install ${PYTHON_PACKAGES[@]} # echo "Installing Ruby gems" # RUBY_GEMS=( # bundler # filewatcher # cocoapods # ) # sudo gem install ${RUBY_GEMS[@]} # NVM and Node echo "Installing NVM..." touch ~/.zshrc curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash # Install latest version nvm install node # echo "Installing global npm packages..." # npm install marked -g echo "Configuring OSX..." # Set moderate key repeat rate defaults write NSGlobalDomain KeyRepeat -int 6 defaults write NSGlobalDomain InitialKeyRepeat -int 25 # Require password as soon as screensaver or sleep mode starts defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 # Show filename extensions by default # defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Enable tap-to-click # defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true # defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 # Enable "natural" scroll defaults write NSGlobalDomain com.apple.swipescrolldirection -bool true # Disable "shake to reveal" defaults write NSGlobalDomain CGDisableCursorLocationMagnification -bool true defaults write NSGlobalDomain com.apple.springing.enabled -bool true defaults write NSGlobalDomain com.apple.springing.delay -float 0.5 defaults write NSGlobalDomain com.apple.mouse.scaling -float 0.6875 defaults write NSGlobalDomain com.apple.trackpad.forceClick -bool true # Disable smart quotes defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false # Expand save panel by default defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true # Save to disk (not to iCloud) by default defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false # Use scroll gesture with the Ctrl (^) modifier key to zoom sudo defaults write com.apple.universalaccess closeViewDFRZoomEnabled -bool false sudo defaults write com.apple.universalaccess closeViewDesiredZoomFactor -float 1.85 sudo defaults write com.apple.universalaccess closeViewHotkeysEnabled -bool false sudo defaults write com.apple.universalaccess closeViewPanningMode -bool true sudo defaults write com.apple.universalaccess closeViewScrollWheelModifiersInt -int 262144 sudo defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true sudo defaults write com.apple.universalaccess closeViewSplitScreenRatio -float 0.2 sudo defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true # Save screenshots to the desktop mkdir ~/00_Screenshots defaults write com.apple.screencapture location -string "~/00_Screenshots" # Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) defaults write com.apple.screencapture type -string "png" # Use list view in all Finder windows by default # Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv` defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" # Keep folders on top when sorting by name defaults write com.apple.finder _FXSortFoldersFirst -bool true # When performing a search, search the current folder by default defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" # Disable shadow in screenshots defaults write com.apple.screencapture disable-shadow -bool true # echo "Creating folder structure..." [[ ! -d ~/Sites ]] && mkdir ~/Sites # Clear all the dumb apps from the Dock # !!! Not idempotent !!! Only run as needed. # defaults write com.apple.dock.plist persistent-apps '' && killall Dock echo "Done. Note that some of these changes require a logout/restart to take effect."