Install macOS

How to make that Mac feel new again.
  1. Generate an SSH key pair
  2. Use Homebrew to manage programs
    1. Install Homebrew
    2. Upgrades
    3. Status
    4. Clean up
  3. Configure Python
  4. Preferences and settings
    1. Monospace fonts
    2. Color palettes
    3. Atom
    4. Microsoft Excel
    5. Change system defaults
  5. Final steps
  6. References

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

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.

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