Table of Contents
Yet another installation of my personal notes for setting up a new (or cleanly installed) MacOS computer. The process changes just a bit with each new OS version. I will try really hard to reproduce the steps in an order that make then easiest to execute.
This time I need to document some details of the actual clean install process: it seems to have become more complicated to boot from a startup disk containing the Big Sur installer. It was necessary to restart into recovery mode (hold down Command+r) and use the Startup Security Utility (under the Utilities menu) to allow booting from external media and not to require an internet connection to verify the boot media. After this, I was able to select a startup disk by restarting while holding down Option. After running that gauntlet, on to the actual installation process (after which I restarted again in recovery mode and restored the default security settings).
I do copy some things over from my old computer, but it's pretty minimal. Here's the command to gather up what I need to transfer.
tar -cf dotfiles.tar .gitconfig .gnupg .pypirc .ssh .aws .saml2aws .psqlrc .zprofile
It's also handy to know all of the projects I'm working on:
cd ~/src for dname in */.git; do git -C $(dirname $dname) remote -v; done > remotes.txt
Note that none of the steps below require an Apple ID - I held off on signing in until the very end just to see if it was possible.
system settings
turn off spelling autocorrect
System Preferences --> Keyboard --> Text tab --> unselect "Correct spelling automatically" and others
unmap Control + left,right
I use Control plus the left and right arrow keys to move between windows in emacs and tmux, so I disable the defaults.
System Preferences --> Keyboard --> Shortcuts --> uncheck mission control: move left/right a space
Turn on FileVault
System Preferences --> Security & privacy --> FileVault
I used a recovery key option rather than iCloud for my work machine, iCloud for personal
Developer tools
Pretty much the first thing that needs to happen. This can be done from the command line:
xcode-select --install
homebrew
Homebrew no longer requires user-ownership of /usr/local, so things are pretty easy now:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew doctor
homebrew API token
Apparently lots of requests to GitHub via homebrew can hit a rate limit. There's a higher limit if you create an API token. See https://gist.github.com/christopheranderton/8644743
Here's the url for the token creation dialog:
https://github.com/settings/tokens/new?scopes=&description=Homebrew
Make sure that all 'scopes' are unchecked. Once you generate the token, add to your shell profile:
export HOMEBREW_GITHUB_API_TOKEN=token_here
CLI applications
Many packages are installed later with additional elaboration or in as dependencies for other applications; here are some more or less standalone packages that I routinely install.
brew install git && \ brew install wget && \ brew install autojump && \ brew install gcc && \ brew install graphviz && \ brew install latex2rtf && \ brew install pandoc && \ brew install tmux && \ brew install tree && \ brew install fd && \ brew install xsv && \ brew install fzf && \ brew install saml2aws && \ brew install jq
desktop applications
Homebrew installs desktop apps too! (the syntax has changed a bit)
for pkg in dropbox sizeup dash google-chrome mactex iterm2; do brew install --cask $pkg; done
Some of the above (eg, sizeup, dropbox, dash) require licenses and credentials that must be installed interactively.
iTerm2
Install using homebrew above. Update a few settings.
Preferences –> Profiles –> Keys and do these things:
- select "Left/right option key acts as": +Esc
- + –> Keyboard shortcut "OPT+<left arrow>": Send Escape sequence "b"
- + –> Keyboard shortcut "OPT+<right arrow>": Send Escape sequence "f"
(may have to delete or replace an existing mapping)
Default appearance:
- Preferences –> Profiles –> Colors –> Color Presets –> Light Background
- Preferences –> Profiles –> Text –> Change Font –> 14 point
Install shell integration:
curl -L https://iterm2.com/shell_integration/install_shell_integration.sh | bash
- Install python runtime by selecting "Scripts" –> "Manage" –> "Install Python Runtime".
- Enable the Python API under "Preferences" –> "General" –> "Magic"
zsh
Change shell to zsh. I'll just use the zsh shipped with the OS.
chsh -s /bin/zsh $USER
Install my dotfiles (relevant only to me)
cd ~ git clone git@bitbucket.org:nhoffman/dotfiles.git ~/dotfiles/mac/install.py
python
My version of Big Sur provided Python 2.7.16 and 3.9.5. My most recent evolution of managing python interpreters is to use pyenv. See https://realpython.com/intro-to-pyenv/
brew install zlib brew install pyenv brew install pyenv-virtualenv
Install pyenv-update plugin:
git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update
added dotfiles/mac/zsh/pyenv.plugin.zsh
if [[ -d "$HOME/.pyenv" ]]; then # echo "using pyenv" export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" fi
Even though the OS version of python3 (3.9.5) is up to date, also install this version via pyenv to avoid installing packages to create a strict a separation from the system version as possible.
pyenv install -v 3.9.5 pyenv global 3.9.5 pip3 install -U pip wheel
Install 3.8.8 for projects expecting python 3.8
pyenv install -v 3.8.8
emacs
Install latest emacs binary from http://emacsformacosx.com/
Emacs needs a few homebrew packages
brew install libressl brew install aspell brew install gpg
Check out my .emacs.d and run setup scripts.
cd ~ git clone git@github.com:nhoffman/emacs-config.git .emacs.d
Run setup scripts:
cd ~/.emacs.d bin/python-setup.sh
R
I had to give up on installing R with homebrew because it seemed to result in an interpreter that always wanted to install packages from source. So I used the binary from https://cran.r-project.org/bin/macosx/
Some packages that I know I'll need:
R --slave << EOF packages <- c("lattice", "RSQLite", "latticeExtra", "argparse", "data.table", "tidyverse") install.packages(packages, repos="http://cran.fhcrc.org/", dependencies=TRUE, clean=TRUE, Ncpus=4) EOF
Wow, this takes a long time!
Also:
brew install --cask rstudio
postgresql
Install from https://postgresapp.com/downloads.html
This installs multiple versions of postgres. You'll need to add the path to the CLI for the version you want to use to your PATH, eg:
export PATH=/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH