-
-
Save ilaif/76920b1f204d85a6239ef815dd644ac8 to your computer and use it in GitHub Desktop.
Mac OS Bootstrap script to setup common developer tools and settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Bootstrap script for setting up a new macOS machine | |
# | |
# Based on https://gist.github.com/codeinthehole/26b37efa67041e1307db | |
# | |
echo "##############################" | |
echo "#Welcome to MAC bootstrapper!#" | |
echo "##############################" | |
echo "" | |
DO_OMZ=y | |
DO_SCALA=y | |
DO_CONSOLAS=y | |
DO_VIRTENWRAP=y | |
DO_SCREENPASS=y | |
DO_NATURALSCROLL=n | |
DO_AUTOHIDEDOCK=y | |
DO_SHOWHIDEDOCKFASTER=y | |
DO_BLSTARTSCRSAVER=y | |
function question() | |
{ | |
# Print question | |
echo $1 | |
select yn in "yes" "no"; do | |
# Save answer in the given variable | |
case $yn in | |
"yes" ) eval "$2=y"; break;; | |
"no" ) eval "$2=n"; break;; | |
esac | |
done | |
} | |
# Configure installation by user input | |
function configure() | |
{ | |
echo "Great, let me ask you some questions:" | |
echo "" | |
question "Do you wish to install oh-my-zsh?" DO_OMZ | |
question "Do you wish to install scala, sbt and maven?" DO_SCALA | |
question "Do you wish to install Consolas font?" DO_CONSOLAS | |
question "Do you wish to install virtualenvwrapper for python?" DO_VIRTENWRAP | |
question "Require password as soon as screensaver or sleep mode starts?" DO_SCREENPASS | |
question "Use natural scroll?" DO_NATURALSCROLL | |
question "Automatically hide dock?" DO_AUTOHIDEDOCK | |
question "Make hiding and showing dock faster?" DO_SHOWHIDEDOCKFASTER | |
question "Moving to bottom-left corner starts screen saver?" DO_BLSTARTSCRSAVER | |
} | |
echo "Do you want to configure the installation, or use defaults?" | |
select yn in "config" "default" | |
do | |
case $yn in | |
"config" ) configure; break;; | |
"default" ) break;; | |
esac | |
done | |
echo "" | |
# Install maxOS all available updates | |
echo "Updating OSX. If this requires a restart, run the script again." | |
sudo softwareupdate -ia | |
# Install Xcode command line tools | |
echo "Installing Xcode Command Line Tools." | |
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 install coreutils | |
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed | |
brew install findutils | |
# Install Bash 4 and zsh | |
brew install bash zsh | |
# Install oh-my-zsh | |
if [ "$DO_OMZ"="y" ]; then | |
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh | |
fi | |
PACKAGES=( | |
ack | |
autoconf | |
automake | |
git | |
hub | |
jq | |
node | |
python2 | |
python3 | |
ssh-copy-id | |
terminal-notifier | |
the_silver_searcher | |
tmux | |
vim | |
wget | |
curl | |
yarn | |
go | |
unrar | |
mysql | |
terraform | |
) | |
echo "Installing packages..." | |
brew install ${PACKAGES[@]} | |
echo "Installing cask..." | |
brew tap caskroom/cask | |
CASKS=( | |
iterm2 | |
macvim | |
google-chrome | |
slack | |
spectacle | |
vlc | |
robo-3t | |
hammerspoon | |
java | |
google-cloud-sdk | |
docker | |
) | |
echo "Installing cask apps..." | |
brew cask install ${CASKS[@]} | |
if [ "$DO_SCALA"="y" ]; then | |
echo "Installing maven" | |
brew install maven | |
echo "Installing Scala and sbt" | |
brew install scala | |
brew install sbt | |
sbt | |
fi | |
echo "Installing fonts..." | |
brew tap caskroom/fonts | |
FONTS=( | |
font-droidsansmono-nerd-font | |
font-firacode-nerd-font | |
font-hermit-nerd-font | |
font-inconsolata-nerd-font | |
font-liberationmono-nerd-font | |
font-monofur-nerd-font | |
font-mononoki-nerd-font | |
font-mplus-nerd-font | |
font-robotomono-nerd-font | |
font-ubuntumono-nerd-font | |
font-sourcecodepro-nerd-font | |
font-inconsolata-nerd-font | |
font-office-code-pro | |
) | |
brew cask install ${FONTS[@]} | |
if [ "$DO_CONSOLAS"="y" ]; then | |
# Install consolas font | |
brew install cabextract | |
curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe | |
cabextract PowerPointViewer.exe | |
cabextract ppviewer.cab | |
open CONSOLA*.TTF | |
fi | |
echo "Install python virtualenv" | |
pip2 install virtualenv | |
if [ "$DO_VIRTENWRAP"="y" ]; then | |
echo "Install python virtualenvwrapper" | |
pip2 install virtualenvwrapper | |
fi | |
echo "Configuring macOS..." | |
# Make key repeat and initial key repeat faster | |
defaults write -g InitialKeyRepeat -int 15 | |
defaults write -g KeyRepeat -int 1 | |
# Require password as soon as screensaver or sleep mode starts | |
if [ "$DO_SCREENPASS"="y" ]; then | |
defaults write com.apple.screensaver askForPassword -int 1 | |
defaults write com.apple.screensaver askForPasswordDelay -int 0 | |
fi | |
# 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 | |
# Disable "natural" scroll | |
if [ "$DO_NATURALSCROLL"="y" ]; then | |
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false | |
fi | |
# Disable smart quotes as they’re annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false | |
# Disable smart dashes as they’re annoying when typing code | |
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false | |
# Enable full keyboard access for all controls | |
# (e.g. enable Tab in modal dialogs) | |
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 | |
# Automatically hide and show the Dock | |
if [ "$DO_NATURALSCROLL"="y" ]; then | |
defaults write com.apple.dock autohide -bool true | |
fi | |
# Make showing the dock faster | |
if [ "$DO_SHOWHIDEDOCKFASTER"="y" ]; then | |
defaults write com.apple.Dock autohide-delay -float 0; killall Dock | |
defaults write com.apple.dock autohide-time-modifier -float 0.4; killall Dock | |
fi | |
# Disable opening and closing window animations | |
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false | |
# Hot corners | |
# Possible values: | |
# 0: no-op | |
# 2: Mission Control | |
# 3: Show application windows | |
# 4: Desktop | |
# 5: Start screen saver | |
# 6: Disable screen saver | |
# 7: Dashboard | |
# 10: Put display to sleep | |
# 11: Launchpad | |
# 12: Notification Center | |
# Bottom left screen corner → Start screen saver | |
if [ "$DO_BLSTARTSCRSAVER"="y" ]; then | |
defaults write com.apple.dock wvous-bl-corner -int 5 | |
defaults write com.apple.dock wvous-bl-modifier -int 0 | |
fi | |
# Privacy: don’t send search queries to Apple | |
defaults write com.apple.Safari UniversalSearchEnabled -bool false | |
defaults write com.apple.Safari SuppressSearchSuggestions -bool true | |
# Make opening visor for iTerm2 faster | |
defaults write com.googlecode.iterm2 HotkeyTermAnimationDuration -float 0.00001 | |
# Only use UTF-8 in Terminal.app | |
defaults write com.apple.terminal StringEncodings -array 4 | |
echo "Changing shell to zsh" | |
chsh -s /bin/zsh | |
echo "Bootstrapping complete" | |
echo "Manual remaining tasks:" | |
echo "1. Load com.googlecode.iterm2.plist to iTerm from | |
Preferences -> General -> Load preferences from a custom folder or URL. When finished, click enter." | |
echo "2. Log Out and Log In again for all changes to take effect." | |
echo "3. Install gcloud cli tool in link: https://cloud.google.com/sdk/docs/quickstart-macos" | |
echo "4. Install visual studio code." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment