Reinstalling a Mac

14. Mar. 2024

 - Fresh installation

Occasionally it makes sense to reinstall a Mac - e.g. when a new version of macOS becomes available, or if it seems that the Mac has become slower due to the constant installation and uninstallation of programs. In this case, it is recommended to create a bootable installer for macOS, use Disk Utility to erase a Mac and then reinstall macOS. These three steps are well described by Apple itself, which is why they will not be repeated here.

The terminal can then be used to finish setting up the Mac.

Basics

First, we recommend installing Oh My Zsh:

Oh My Zsh is a responsive, open-source, community-driven framework for managing Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes and more.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Package management

Similar to apt under Linux, there is also a management tool for programs and packages for macOS. It is called Homebrew and is installed as follows:

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

To run Homebrew when the terminal is started, the file .zshrc must be added to the home directory, which is done as follows:

echo '' >> ~/.zprofile
echo 'if [ -e /opt/homebrew/bin/brew ]; then' >> ~/.zprofile
echo '    eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
echo 'fi' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Rosetta

Since not all programs have been compiled for Apple chips, Apple provides a translation process called Rosetta. This translation process makes it possible to run programs compiled for x86_64 on a Mac with Apple chips, i.e. arm64. Rosetta is installed automatically as soon as it detects that an x86_64 program is to be executed. However, you can also initiate the installation yourself:

sudo softwareupdate --install-rosetta

Apps

Now Homehrew can be used to install programs or apps (in Homebrew-speak so-called "Casks"). For Python development I recommend pyenv:

brew install pyenv
echo '' >> ~/.zprofile
echo 'if [ -e /opt/homebrew/bin/pyenv ]; then' >> ~/.zprofile
echo '    export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zprofile
echo '    [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zprofile
echo '    eval "$(pyenv init -)"' >> ~/.zprofile
echo 'fi' >> ~/.zprofile

To access the Apple Store so that apps that are not provided via Homebrew can be installed via the terminal, I recommend mas:

brew install mas
mas install 441258766 # Magnet
mas install 497799835 # Xcode
mas install 409201541 # Pages
mas install 409203825 # Numbers
mas install 409183694 # Keynote
mas install 1501592214 # Twingate

And apps (or "Casks") that I often use are the following:

brew install --cask \
    docker \
    citrix-workspace \
    istat-menus \
    bartender \
    visual-studio-code \
    nextcloud \
    fujitsu-scansnap-home \
    devonthink \
    microsoft-excel \
    microsoft-word \
    microsoft-powerpoint \
    microsoft-teams \
    blender \
    handbrake \
    spotify \
    minecraft

Since I also use SDL (e.g. for Pygame), I also install the necessary binaries:

brew install sdl2 sdl2_mixer sdl2_image sdl2_ttf sdl2_gfx

And now the Mac is freshly set up and ready for work and coding!

References