Clean install of MacOS Catalina

Sat 11 April 2020 — Filed under notes; tags: mac

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. This time I will try really hard to reproduce the steps in order.

I definitely carry 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 .Xmodmap .gitconfig .gnupg .pypirc .ssh .aws .saml2aws

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 these steps 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.

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 GutHub 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

desktop applications

Homebrew installs desktop apps too!

brew cask install dropbox
brew cask install sizeup
brew cask install dash
brew cask install google-chrome
brew cask install java
brew cask install mactex
brew cask install texmaker
brew cask install firefox
brew cask install docker

Some of the above (eg, sizeup, dropbox, dash) require licenses and credentials that must be installed interactively.

packages in 3rd party taps

saml2aws

brew tap versent/homebrew-taps
brew install saml2aws

iTerm2

The homebrew version gave an error on launch with a message about not being supported on Catalina, and rather than fight with it, I just downloaded an installer from the project site.

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"

Default appearance:

  • Preferences –> Profiles –> Colors –> Color Presets –> Light Background
  • Preferences –> Profiles –> Text –> Change Font –> 14 point

python

My version of Catalina provided Python 2.7.16 and 3.7.3, so let's use homebrew to get recent version of python3.

I try to limit packages installed to the system to utilities that are very frequently used outside of the context of a virtualenv.

See https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md

dependencies

Run brew info python for required and optional dependencies

for pkg in sphinx-doc pkg-config readline sqlite gdbm berkeley-db@4 tcl-tk xz; do brew install $pkg; done

Note that "python" corresponds to the python3 homebrew recipe.

brew install python
/usr/local/bin/pip3 install -U pip wheel

A limited selection of packages - better to use virtualenvs!

pip3 install --user ansible

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

zsh

Install zsh with Homebrew

brew install zsh

Change shell to zsh

sudo -s
echo /usr/local/bin/zsh >> /etc/shells
exit
chsh -s /usr/local/bin/zsh $USER

Install my dotfiles (relevant only to me)

cd ~
git clone git@bitbucket.org:nhoffman/dotfiles.git
~/dotfiles/mac/install.py

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 cask install rstudio

postgresql

brew cask install postgres

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

X11

install Xquartz

brew install caskroom/cask/xquartz

X11 key bindings so that the option key is used for Meta. Not so relevant any more now that I rarely use emacs via X11 for remote sessions.

cat > ~/.Xmodmap <<EOF
clear Mod1
clear Mod2
keycode 63 = Mode_switch
keycode 66 = Meta_L
add Mod1 = Meta_L
add Mod2 = Mode_switch
EOF