Every year I do a clean install of the latest macOS, to mostly get rid of the things I accumulated throughout the year that I no longer use and force myself to do some house keeping. Whether after a clean install or just getting my hands on a new Mac, I find myself doing the same setup process every time - I mostly rely on a python 2 setup. In this post, I document this workflow for my future self and hopefully for the benefit of others.

Before

Back in the day, backing up all my data just before a clean install was a painful process but thanks to iCloud, which now takes care of backing up my bookmarks, passwords, etc, it is now a straightforward step. All I have to do is copy my files in ~/[username] to an external hard drive. P.S. I do this in addition to the Time Machine backup just in case!

Format

Prepare a bootable macOS installer, erase the main drive, and install the OS. A nice guide for this can be found here.

Setup

Xcode

First, we’ll install Xcode and the Command Line Tools from the App Store. Don’t forget to accept the license agreement after installation before moving on.

Settings & Software

Second, while Xcode is installing, copy your files back and change the trackpad, keyboard, users, etc. settings to your liking. I also have a bunch of dot files that contain paths, aliases, etc. to make things easier. I keep these files in this Github repository, some of these files might be useful.

Also, install your favorite text editor, TeX / iWork / Office, and other software you regularly rely on; as well as, themes and colors.

Package Manager

The remainder of the workflow will be run from the terminal.

Install a package manager, Brew (or Macports):

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

Some Standard Packages

A version control system - Git (or preferred alternative):

brew install git
git config --global user.name "Your Name Here"
git config --global user.email "your_email@youremail.com"
git config --global credential.helper osxkeychain

Python:

brew install python

We’ll need to add the new python to the path: PATH="/usr/local/opt/python/libexec/bin:$PATH"

The world’s best text editor :) - Vim:

brew install vim

Pathogen makes it easy to install vim plugins:

mkdir -p ~/.vim/autoload ~/.vim/bundle && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Some minimal sensible vim settings:

cd ~/.vim/bundle
git clone git://github.com/tpope/vim-sensible.git

It’s almost always useful to have Node installed:

brew install node
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

This website is built with jekyll and like Node, it’s useful to a have Ruby and RVM installed:

curl -L https://get.rvm.io | bash -s stable --ruby
gem install jekyll

Scientific Stack

A C compiler - GCC; this is also a dependency for later packages:

brew install gcc

Virtualenv is a tool to create isolated environments that is very handy in managing multiple python projects that require different dependencies:

pip install virtualenv

IPython and Jupyter are two great tools for interactive python:

brew install zeromq
brew install pyqt
pip install ipython
pip install jupyter

The usual suspects NumPy, SciPy, MatPlotLib:

pip install numpy
pip install scipy
pip install matplotlib

(While you’re at it, do consider donating :) to the open-source community.)

Finally, the machine learning toys - tensorflow and scikit-learn:

pip install tensorflow
pip install scikit-learn

We’ll have to visit PyTorch’s website to install the latest PyTorch; or the current preferred tool.

End

That’s All Folks! I find this to be a minimal setup to get up and running. Other tools can be installed later when needed and probably within the project scope.