Skip to content

Instantly share code, notes, and snippets.

@auryn31
Forked from codeinthehole/osx_bootstrap.sh
Last active June 22, 2022 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auryn31/c5611eb41cce13a004044d57367188e1 to your computer and use it in GitHub Desktop.
Save auryn31/c5611eb41cce13a004044d57367188e1 to your computer and use it in GitHub Desktop.
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Apps without brew installation:
# - Magnet https://magnet.crowdcafe.com https://apps.apple.com/app/id441258766?mt=12
#
#
# 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.
#
# Important:
#
# - After you run the script and logged in into dropbox, restore settings for apps with
# => mackup restore
#
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
NONE='\033[00m'
RED='\033[01;31m'
function printInfo {
echo -e "${BOLD}${RED}\n$1\n${NORMAL}${NONE}"
}
function notifyInfo {
echo $1 | terminal-notifier -sound default
}
printInfo "Starting bootstrapping"
# Check for Homebrew, install if we don't have it
if test ! $(which brew); then
printInfo "Installing homebrew..."
/usr/bin/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
brew install gnu-sed
brew install gnu-tar
brew install gnu-indent
brew install gnu-which
brew install grep
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
brew install findutils
# Install Bash 4
brew install bash
PACKAGES=(
ack
ansible
awscli
bash-completion
bat
docker
ffmpeg
flatbuffers
fzf
go
gifsicle
git
git-flow
git-lfs
graphviz
helm
htop
hub
httpie
jq
kubectl
mackup
markdown
maven
micronaut
minikube
npm
nvm
protobuf
pandoc
python3
pypy3
rename
redis
terminal-notifier
tmux
tree
vim
wget
youtube-dl
ytop
)
printInfo "Installing packages..."
for package in ${PACKAGES[@]}
do
brew list $package && brew upgrade $package || brew install $package
done
printInfo "Cleaning up..."
brew cleanup
printInfo "Installing cask apps..."
APPS=(
basictex
calibre
chromedriver
dropbox
deepl
docker
dbeaver-community
google-chrome
iterm2
slack
visual-studio-code
java
postman
tex-live-utility
spotify
intellij-idea
kitematic
gitkraken
robo-3t
omnidisksweeper
whatsapp
deepl
grammarly
gimp
visualvm
vlc
dozer
runjs
notion
)
for app in ${APPS[@]}
do
brew list --cask $app || brew install --cask $app
done
printInfo "Installing fonts..."
brew tap homebrew/cask-fonts
FONTS=(
font-inconsolata
font-roboto
font-clear-sans
font-fira-code
font-fira-code-nerd-font
font-hack-nerd-font
font-3270
font-3270-nerd-font
font-victor-mono
)
brew cask install ${FONTS[@]}
printInfo "Installing global npm packages..."
npm install marked -g
npm install typescript -g
npm install yarn -g
npm install serverless -g
printInfo "Install oh my zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
printInfo "Install Rust..."
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
# https://sdkman.io/install
printInfo "Install SDKMan..."
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
printInfo "Configuring OSX..."
# Trackpad: enable tap to click for this user and for the login screen
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Trackpad: drag and move with three fingers --> Require restart
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true
# Key is repead when hold
defaults write -g ApplePressAndHoldEnabled -bool false
# Set speed of repetition to fastest
defaults write NSGlobalDomain KeyRepeat -int 4
# Set wait until repead to 15ms
defaults write NSGlobalDomain InitialKeyRepeat -int 25
# Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Save screenshots to the desktop
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"
###############################################################################
# Finder #
###############################################################################
# Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
# Show icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowMountedServersOnDesktop -bool false
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false
# Show filename extensions by default
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Show hidden files
defaults write com.apple.Finder AppleShowAllFiles true
# Allowing text selection in Quick Look/Preview in Finder by default
defaults write com.apple.finder QLEnableTextSelection -bool true
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Avoid creating .DS_Store files on network or USB volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Disable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false
# Show the ~/Library folder
chflags nohidden ~/Library
###############################################################################
# Dock, Dashboard, and hot corners #
###############################################################################
# Enable highlight hover effect for the grid view of a stack (Dock)
defaults write com.apple.dock mouse-over-hilite-stack -bool true
# Set the icon size of Dock items to 48 pixels
defaults write com.apple.dock tilesize -int 48
# Show indicator lights for open applications in the Dock
defaults write com.apple.dock show-process-indicators -bool true
# Show only open applications in the Dock
defaults write com.apple.dock static-only -bool true
# Speed up Mission Control animations
defaults write com.apple.dock expose-animation-duration -float 0.2
# Group windows by application in Mission Control
# (i.e. use the old Exposé behavior instead)
defaults write com.apple.dock expose-group-by-app -bool true
# Remove the auto-hiding Dock delay
defaults write com.apple.dock autohide-delay -float 0
# Set the animation speed when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0.5
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
###############################################################################
# Safari & WebKit #
###############################################################################
# Privacy: don’t send search queries to Apple
defaults write com.apple.Safari UniversalSearchEnabled -bool false
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
# Press Tab to highlight each item on a web page
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
# Set Safari’s home page to `about:blank` for faster loading
defaults write com.apple.Safari HomePage -string "about:blank"
# Prevent Safari from opening ‘safe’ files automatically after downloading
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
# Allow hitting the Backspace key to go to the previous page in history
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
# Hide Safari’s bookmarks bar by default
defaults write com.apple.Safari ShowFavoritesBar -bool false
# Hide Safari’s sidebar in Top Sites
defaults write com.apple.Safari ShowSidebarInTopSites -bool false
# Enable Safari’s debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Make Safari’s search banners default to Contains instead of Starts With
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
# Remove useless icons from Safari’s bookmarks bar
defaults write com.apple.Safari ProxiesInBookmarksBar "()"
# Enable the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
# Add a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
# Disable auto-correct
defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false
###############################################################################
# Mail #
###############################################################################
# Copy email addresses as `foo@example.com` instead of `Foo Bar <foo@example.com>` in Mail.app
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
# Load new settings before rebuilding the index
killall mds > /dev/null 2>&1
# Make sure indexing is enabled for the main volume
sudo mdutil -i on / > /dev/null
# Rebuild the index from scratch
sudo mdutil -E / > /dev/null
###############################################################################
# Terminal & iTerm 2 #
###############################################################################
# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4
# Don’t display the annoying prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool false
###############################################################################
# Kill affected applications #
###############################################################################
for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
"Dock" "Finder" "Mail" "Messages" "Photos" "Safari" \
"SizeUp" "Spectacle" "SystemUIServer" "Terminal" "Transmission" "iCal"; do
killall "${app}" &> /dev/null
done
echo "Done. Note that some of these changes require a logout/restart to take effect."
printInfo "Cleanup cache"
brew cleanup -s
notifyInfo "Bootstrapping complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment