Setting up a new mac for programming

Multiple versions of this document exist, and since I’ve had to set up new Macs a lot lately, so here is mine :)

Programs downloadable via homebrew

Homebrew is a great macOS package manager, Once homebrew is installed, most of the other programs can be installed bia brew formulae and their locations and dependencies are also checked automatically. Therefore, I usually start with the programs that can be installed here:

  • iTerm2, a fancy kind of terminal app: brew install --cask iterm2
  • VSCode, a text editor that can handle multiple programming languages: brew install --cask visual-studio-code
  • Sublime a customizable text editor I use for python, bash and markdown files: brew install --cask sublime-text. You can configure this program to launch from terminal.
  • R a statistical programming language: brew install --cask r

Programs which require direct download

Next, these helpful programs cannot be installed via homebrew:

  • Miniconda: a lightweight version of conda, the ubiquitous package manager for python, which comes with python and the most basic packages like zlib. There is an apple silicon version of the macOS installer.
  • Zoom: there is now an apple silicon version of this video calling program.
  • Coconut battery: a handy program which reports battery health according to the same information that can be found with ‘ioreg’ command in bash.
  • Al Dente: this reddit-recommended tool has helped keep my macbook battery health really high by charging only up to a user-defined limit (in my case 68%). The free version is already quite useful.

Terminal configuration with iTerm2 and zsh themes for git

Though iTerm makes working in terminal super nice, there are some additional enhancements.

  • connect with Github: access to Github can be established by generating and adding a new ssh key.
  • configure the zsh theme: a bunch of themes are available to replace the default terminal prompt and make the terminal look cool. For some of the zsh themes, because of the symbols used, a special font is required. For instance, here are the instructions for the agnoster theme which uses prompts that work with git.
  • color scheme: Navigate to iTerm2 > Preferences > Profiles > Colors > Color Presets to change the default background color of the terminal.

Working remotely via sshfs

The external compute cluster can be loaded like a USB drive using oxfuse and sshfs. As of October 2022, this can be done in the following steps.

  1. Install sshfs with homebrew: brew install sshfs
  2. Install macfuse: brew install macfuse
  3. After installation, when using this software, will need to enable third party extension according to these instructions. As part of this process, you will be prompted to restart your mac into Recovery mode, where you can change the Security Policy from Full Security to Reduced Security.
  4. Add bash aliases for the necessary commands into .zshrc. For example, I saved commands to open the locations of my project folders on the remote disk.

Working in R

I work with Rstudio for R programs, an IDE for working with R that makes it easy to look at plots and objects within the current working environment. This can be downloaded via homebrew using brew install --cask rstudio. Here are the settings I change off the box:

  • add shortcuts: to be consistent with other text programs (e.g. sublime, overleaf) replace shortcut for commenting with command-slash using ‘configure Tools > Modify Keyboard Shortcuts’
  • disable reloading of workspace: for some reason RStudio by default tends to save snapshots of the work environment when closed which can cause lag and confusion. To disable this behaviour, you can go to RStudio > Preferences and uncheck the three boxes that begin with ‘Restore’ e.g. ‘Restore most recently opened project at startup’
  • change the color scheme: It can be set to dark mode by going to RStudio > Preferences > Appearance.
Written on January 5, 2022