Mac M2 Ventura setup

Wed 19 April 2023 — Filed under notes; tags: mac

Yet another installation of my personal notes for setting up a new (or cleanly installed) MacOS computer. Not too many changes since Monterey. I will try really hard to reproduce the steps in an order that make then easiest to execute.

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.

bootstrapping from another system

I do copy some things over from my previous computer, but it's pretty minimal. Here's the command to gather up what I need to transfer.

tar --exclude '.gnupg/S.*' -cf dotfiles.tar .aws .gitconfig .gnupg .netrc .pypirc .saml2aws .ssh

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

system update

The first thing I did this time around was to perform a system software update to get all of that waiting out of the way.

Developer tools

Also takes a while. This can be done from the command line:

xcode-select --install

system settings

The new iOS-style System Settings takes a bit of getting used to.

turn off spelling autocorrect

Search for "spelling" --> 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. Disable the default mapping to mission control:

System Settings --> Keyboard Shortcuts pane --> Keyboard Shortcuts button --> uncheck mission control: move left/right a space

Turn on FileVault

System Settings --> Security & privacy --> FileVault

I used a recovery key option rather than iCloud for my work machine, iCloud for personal

homebrew

Still a one-liner, now bash rather than ruby:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew doctor

Homebrew is installed to /opt/local on an M1 Mac. This required updating my PATH configuration. I added the following to my login profile:

if [[ -d /opt/homebrew ]]; then
    eval "$(/opt/homebrew/bin/brew shellenv)"
fi

The new location required a number of changes to various login steps configuring homebrew-installed components.

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 up front.

brew install git && \
brew install wget && \
brew install autojump && \
brew install gcc && \
brew install graphviz && \
brew install latex2rtf && \
brew install mcfly && \
brew install pandoc && \
brew install pngpaste && \
brew install tmux && \
brew install tree && \
brew install fd && \
brew install xsv && \
brew install fzf && \
brew install saml2aws && \
brew install jq && \
brew install duckdb && \
brew install fswatch && \
brew install node && \
brew install htop

desktop applications

Homebrew installs desktop apps too! (the syntax has changed a bit)

for pkg in 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

zsh is the default shell on MacOS.

Install my dotfiles.

cd ~
git clone git@github.com:nhoffman/dotfiles.git
~/dotfiles/mac/install.py

python

Ventura ships with Python 3.9.6 as /usr/bin/python3 with no python executable (or maybe it's installed with xcode tools - I forgot to check). That's nice, but I avoid using the system python for the most part.

pyvenv

My current method for 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

Install the most recent versions of 3.8, 3.9 and 3.10 and set 3.10 as the default.

pyenv install $(pyenv install -l | grep '^  3.8' | tail -n1)
pyenv install $(pyenv install -l | grep '^  3.9' | tail -n1)
pyenv install $(pyenv install -l | grep '^  3.10' | tail -n1)
pyenv install $(pyenv install -l | grep '^  3.11' | tail -n1)
pyenv global $(pyenv install -l | grep '^  3.11' | tail -n1)
python3 -m pip install -U pip wheel

pyenv seems not to install a python entrypoint. I'll see how it goes with python3 only.

pipx

I'm trying out pipx for installing standalone python-language commands outside of project-level virtual environments.

pipx recommends installation from homebrew, so that's what we'll go with:

brew install pipx

The installation instructions include running pipx ensurepath, but this appears not to be necessary if ~/.local/bin is already added to your PATH.

Install some globally useful packages:

pipx install awscli
pipx install pgcli

emacs

Since I moved off of Intel macs, I have been using the Homebrew emacs-plus project, which seems great so far.

brew install libressl
brew install aspell
brew install gpg
brew tap d12frosted/emacs-plus
brew install emacs-plus

Edit: after emacs 39.1 came out, I updated with:

brew uninstall emacs-plus
brew install emacs-plus@29 --with-imagemagick --with-native-comp

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

The main inconvenience was having to adapt my startup script to juggle M1 Mac, x86 Mac, and linux. Here's the relevant portion.

if [[ $(uname) == 'Darwin' ]]; then
    if [[ $(uname -m) == 'arm64' ]]; then
	# assume we are using emacs-plus
	EMACS=/opt/homebrew/bin/emacs
	EMACS_BIN=/opt/homebrew/bin/emacsclient
    else
	EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs
	EMACS_BIN=/Applications/Emacs.app/Contents/MacOS/bin
    fi
    alias emacs="$EMACS"
    # provides emacsclient
    export PATH=$EMACS_BIN:$PATH
else
    EMACS=$(readlink -f emacs)
fi

R

Installed with brew install --cask r.

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. My zsh profiile includes the path to the CLI for the latest version, eg:

PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"

Docker desktop

Use Homebrew.

brew install --cask docker

Mac M1 Monterey setup

Sat 23 July 2022 — Filed under notes; tags: mac read more

Yet another installation of my personal notes for setting up a new (or cleanly installed) MacOS computer …

Clean install of MacOS Big Sur

Thu 20 May 2021 — Filed under notes; tags: mac read more

Yet another installation of my personal notes for setting up a new (or cleanly installed) MacOS computer. The …

Clean install of MacOS Catalina

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

Clean install of MacOS Mojave

Fri 15 February 2019 — Filed under notes; tags: mac read more

Clean install of MacOS High Sierra

Fri 17 November 2017 — Filed under notes; tags: mac read more

Setting up a new Mac (Sierra)

Thu 05 January 2017 — Filed under notes; tags: mac read more

Setup after clean install of El Capitan

Mon 02 November 2015 — Filed under notes; tags: mac read more

Setup for VirtualBox VM running Ubuntu 14.04 on OS X Mavericks

Fri 06 February 2015 — Filed under notes; tags: linux, mac, virtualbox read more

Here are my notes for setting up an Ubuntu VM to work on some web applications. This is intended to be a sandbox for development, so I'll err on the side of convenience (at …

Setting up a new mac

Sun 20 October 2013 — Filed under notes; tags: mac read more