Install macOS

How to make that Mac feel new again.

Generate an SSH key pair

First, check to see if one already exists.

ls -l ~/.ssh/id_rsa*
# Remove existing keys
rm ~/.ssh/id_rsa*

Create a new keypair.

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -C <EMAIL>

On macOS Sierra, you have to enable keychain storage in ~/.ssh/config to save your passphrase.

Host *
    UseKeychain yes

Add the newly created private key to the macOS keychain.

ssh-add -K ~/.ssh/id_rsa

Copy the public key to the clipboard.

cat ~/.ssh/id_rsa.pub | pbcopy

Add your newly created public key to the ~/.ssh/authorized_keys file of the remote server. Be sure to ensure the correct permissions of both the remote ~/.ssh folder (700) and ~/.ssh/authorized_keys (600).

Use Homebrew to manage programs

Homebrew is an incredibly useful package and application manager for macOS.

Install Homebrew

Create sbin/ directory and set permissions.

sudo mkdir -p /usr/local/sbin/
sudo chown -R $(whoami) /usr/local/sbin/

Install Xcode command line tools (CLT).

xcode-select --install

Run the Homebrew install script.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

For reference, here’s how to uninstall.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Upgrades

Homebrew needs to be updated on a regular schedule.

brew update
brew upgrade
brew cask outdated | xargs brew cask reinstall

Status

echo "Homebrew leaves ===="
brew leaves

echo "Homebrew versions ===="
brew list --versions

echo "Homebrew dependencies ===="
brew deps --installed --tree
brew outdated
brew cask outdated
brew missing

echo "Homebrew doctor ===="
brew doctor

Clean up

Periodically, clean up should be performed. Otherwise, downloaded installers will take up a lot of local disk space, and can max out an SSD.

brew cleanup -s
brew cask cleanup
brew prune

Casks are recipes that manage installation of GUI macOS applications, such as Google Chrome and RStudio.

Note that R should be installed using brew cask install r instead of brew install r. This command will install the latest official R.app binary, which has two main advantages: (1) support in the RStudio IDE, and (2) fast downloading of pre-compiled packages from CRAN.

# Priority
brew cask install java osxfuse xquartz

brew cask install 1password
brew cask install alfred
brew cask install aspera-connect
brew cask install atom
brew cask install authy
brew cask install basictex
brew cask install bbedit
brew cask install bibdesk
brew cask install coconutbattery
brew cask install coda
brew cask install cyberduck
brew cask install docker
brew cask install emacs
brew cask install fiji
brew cask install firefox
brew cask install github
brew cask install google-chrome
brew cask install google-cloud-sdk
brew cask install google-drive-file-stream
brew cask install gpg-suite
brew cask install hazel
brew cask install igv
brew cask install iterm2
brew cask install keka
brew cask install kid3
brew cask install libreoffice
brew cask install omnidisksweeper
brew cask install onyx
brew cask install r-app
brew cask install rstudio
brew cask install safari-technology-preview
brew cask install skype
brew cask install spillo
brew cask install superduper
brew cask install torbrowser
brew cask install transmit
brew cask install tunnelblick
brew cask install visual-studio-code
brew cask install vlc
brew cask install xld
brew cask install wine-devel

# These apps have permission issues with non-admin accounts:
# - carbon-copy-cloner
# - dropbox
# - little-snitch
# - slack

# Note that XQuartz v2.7.11 doesn't work well with wine.
# Install v2.7.9 directly instead.
# https://www.xquartz.org/releases/XQuartz-2.7.9.html
# brew cask install xquartz
# Use CRAN R cask (R.app) instead of Homebrew R.

# Homebrew now supports a global variable to force bottle installations.
# Alternatively, can use `--force-bottle`.
# See also:
# - https://github.com/Homebrew/brew/pull/4520/files
# - https://github.com/Homebrew/brew/pull/4542/files
export HOMEBREW_FORCE_BOTTLE=1

# Priority
brew install flac lame tcl-tk

# Shells
brew install bash fish ksh tcsh zsh

brew install autoconf
# Amazon AWS CLI enables S3 bucket access.
brew install awscli
brew install automake
brew install bash-completion
# bfg requires Java 1.7+.
brew install bfg
brew install ccache
brew install circleci
brew install cmake
brew install convmv
brew install coreutils
brew install curl
# exa is a modern replacement for ls.
brew install exa
brew install exiftool
brew install ffmpeg
brew install findutils
brew install flac
brew install gcc
brew install gdal
brew install git
brew install git-lfs
brew install gsl
# Reinstall hdf5 from source if you see this:
# Warning: hdf5 dependency gcc was built with a different C++ standard
# library (libstdc++ from clang). This may cause problems at runtime.
# brew reinstall hdf5 --build-from-source
# Otherwise hdf5 in R can have issues.
brew install hdf5
brew install hub
# Additional imagemagick flags:
# - `--with-ghostscript`
# - `--with-pango`
# - `--with-webpbrew`
brew install imagemagick --with-fontconfig --with-librsvg
brew install leiningen
brew install libav
brew install libgit2
brew install libiconv
brew install libressl
brew install librsvg
brew install libssh2
brew install libxml2
brew install libxslt
# LLVM full mainline: `--with-toolchain` (very slow to install).
brew install llvm
# Install MariaDB instead of MySQL.
brew install mariadb-connector-c
brew install mas
# This will install md5sum.
brew install md5sha1sum
brew install neovim
brew install node
# OpenBLAS is very CPU intensive when built from source.
brew install openblas --with-openmp
brew install pandoc
brew install pandoc-citeproc
brew install pandoc-crossref
brew install pkg-config
brew install protobuf
brew install python --with-tcl-tk
brew install rsync
brew install rbenv
brew install screen
brew install shellcheck
brew install sshfs
brew install sox --with-flac --with-lame
brew install tesseract
brew install tmux
brew install trash
brew install tree
brew install udunits
brew install vim
brew install wget
brew install winetricks
brew install youtube-dl
brew install zlib

# Cask repair (for pull requests).
brew install vitorgalvao/tiny-scripts/cask-repair

Configure Python

Python is useful for scripting workflows. Homebrew can manage installations of both versions 2 and 3 and the launcher application automatically.

pip install --upgrade pip setuptools
pip3 install --upgrade pip setuptools wheel

Preferences and settings

Monospace fonts

Color palettes

Download the base16 templates:

Ocean is the preferred color scheme.

Download our Coda.app and Terminal.app profiles.

Atom

r-exec enables the user to run R code directly from Atom.

apm install r-exec

Microsoft Excel

Change system defaults

Unhide the user library.

chflags nohidden ~/Library

Speed up user interface animations.

defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -int 0
defaults write com.apple.finder DisableAllAnimations -bool true
defaults write NSGlobalDomain NSWindowResizeTime .001
killall Dock
killall Finder

Don’t write .DS_Store files to network storage.

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Save screenshots into ~/Documents/, instead of ~/Desktop/.

screenshots_dir="${HOME}/Documents/Screenshots"
mkdir -p "$screenshots_dir"
defaults write com.apple.screencapture disable-shadow -bool true
defaults write com.apple.screencapture location "$screenshots_dir"
defaults write com.apple.screencapture name Screenshot
killall SystemUIServer

Disable podcasts in iTunes.

defaults write com.apple.itunes disablePodcasts -bool YES

Final steps

References