Setting up a new Mac

6 minute read

I’ve just got hold of a new Mac laptop to replace my previous one, which has started showing signs of aging. I thought it could be useful for the PhD students and postdoctoral researchers that will join my group during the next months, and will decide to buy a Mac, to write down the applications I like to install on every Mac I use, for my academic work. The focus of this document will be only on applications that are available for free. I use also proprietary software. But since this software can be found and installed via well-documented platforms provided by our university, there is little value in discussing it here.

In a series of future posts, I will also describe how I use all these applications. The instructions below may contain errors, so use them at your own risk. If you find some issues or discover that some information provided here is outdated, please let me know, and I will try to rectify it.

Homebrew

Homebrew is a package manager for MacOS. Essentially, it allows one to install and update applications similar to a Linux distribution. We will use it to install and maintain many great tools. To install homebrew follow the instructions on the Homebrew website. Note: the homebrew installer will also download and install the Command Line Tools for Xcode, which are needed to compile source file. Homebrew allows you also to keep all your packages updated. Just type in the terminal

brew update
brew outaded

To verify which of the installed packages have an update version available. Then use

brew upgrade

followed by the name of the desired package, to update it.

Fonts for terminal and other applications

I like to use the fonts Jetbrains Mono Nerd Font and Sauce Code Pro Nerd Font in some of my applications. Let us install it via homebrew

brew install --cask homebrew/cask-fonts/font-jetbrains-mono-nerd-font
brew install --cask homebrew/cask-fonts/font-sauce-code-pro-nerd-font

Kitty and terminal improvements

Let us replace the terminal app in the MAC with something that is more configurable. I chose kitty, which we can install again via homebrew

brew install --cask kitty

Kitty can be set up via a .conf configuration file, which needs to be placed in ./config/kitty.

Let us now make the use of the terminal (which is central in my academic work flow) a bit more pleasant. First of all, let us install oh-my-zsh, a framework for managing zsh configurations, by following the instructions in their website. Then let us use homebrew again to install powerlevel10k to make the terminal look nicer:

brew install romkatv/powerlevel10k/powerlevel10k
echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc

A configuration wizard will guide you through the configuration options. You can restart the wizard at any time by typing p10k configure

A tool that I use very often when working on the command line is zsh-z, which allows me to jump quickly to directories that I have visited recently. This is so much more convenient than navigating my file system using the finder app. To activate this plugin, just open the file .zshrc in your home directory and replace the line plugin=(git) with the line plugin=(git z).

Python

Let us now set up python, which has become an invaluable tool for both research and teaching. A brand new MacOS comes with its own version of python. I prefer to set one up myself for a better control. The following instructions are taken from the following excellent article. Let us first use homebrew to install pyenv, which we will use to manage the python versions.

brew install pyenv

Then we use pyenv to install the desired version of python (the latest one being python 3.12.1 at the time of writing)

pyenv install 3.12.1

Finally, we set this version as default python version

pyenv global 3.12.1

Finally, to have control on the shell path, type the following line command

echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc

which adds a similar line in the .zshrc file.

Neovim

I currently use neovim as my editor for latex, markdown, sometimes python, and the various configuration files. It integrates very well with my terminal flow. It can as usual be installed via homebrew

brew install neovim

Neovim is highly customizable (via the Lua language), which may actually be an issue for new users. A good starting point is the following configuration file. It configures autocompletion, language server protocols, snippets, themes, fuzzy finders, and more. Once you start neovim, it is a good idea to run the function :Checkhealth to verify whether additional packages should be installed. Alternative (pre-configured) starting points are LazyVim and NvChad. I currently use LazyVim with the lang.tex extension for latex.

Tmux

Tmux is a terminal multiplexer, i.e., a tool to have multiple sessions, windows, and panes in the terminal. I use Tmux to switch between multiple tasks effectively (e.g., writing a paper and preparing some lecture notes), while keeping all the needed files opened the whole time. This is particularly useful when working on a desktop computer, since I reboot it rarely. Tmux can be installed as usual via homebrew

brew install tmux

Similar to the other programs, it can be configured via a config. file .tmux.config in the home directory.

Doom Emacs

I use emacs mainly to

  1. maintain my todo lists, keep track of deadlines, and progress towards my objectives via the fantastic org mode package,
  2. to create and link research and management notes via org-roam, and
  3. to keep track of interesting papers to read via elfeed, produce notes linked to the articles via citar and link articles to my notes via org-cite.

Emacs is highly customizable. I find Doom Emacs an excellent configuration framework, which can be used as a good starting point for customizing emacs. It also uses vim keybindings, which fits my flow nicely. Also it installs automatically most of the packages I need and it configures them reasonably. To install a version of Emacs for macOS that plays well with the Doom Emacs framework, use the following commands

brew tap railwaycat/emacsmacport
brew install --build-from-source --debug-symbols railwaycat/emacsmacport/emacs-mac --with-modules --with-native-comp --with-starter --with-unlimited-select --with-xwidgets --with-tree-sitter

Then proceed as described here. Doom emacs requires ripgrep and fd for fast file search. You can install both of them via homebrew

brew install ripgrep fd

Additional programs (to be installed via homebrew) may be useful; run doom doctor to figure out what else you may want to install

Latex

To install latex on macOS, I use MacTeX. It also installs by default Bibdesk, which is an excellent .bib file manager. I use it also to archive in an effective way the .pdf of the papers saved in my .bib file. It also integrates well with doom emacs, provided that citation keys and pdf names are synchronized.

Skim

Skim is a simple pdf reader that integrates well with latex, syntex, and pdfsync. This means that it supports both forward and inverse search when used as output of the compilation of a .tex file. As usual, it can be installed using homebrew

brew install --cask skim

I have tried other pdf readers: some of them such as zathura allow for dark background and vim keybindings. However, I find them less stable than skim on MacOS when used together with neovim. Of course, one can use doom emacs to edit latex as well (with its native pdf reader), but I find neovim somewhat more convenient to use for my flow.

Unison

One issue with having a desktop computer together with a laptop, is that I need to keep them synchronized. To do so, I use Unison. It can as usual be installed via homebrew

brew install unison

To use unison, one needs to create a profile file and place it in /Library/Application Support/Unison The profile file is a .prf file that contains information related to the machine that need to be synchronized as well as a list of directories over which the program will act and of files extensions to ignore.

Amethyst

Amethyst is a tiling window manager for macOS, similar to the ones available on Linux platforms. It makes easier to organize windows within a macOS space' and to move windows across spaces’. As usual, it can be installed via homebrew

brew install --cask amethyst