Use a custom .zshrc with iTerm2

30 Sep 2021 in TIL

We're trying to make all of our screencasts look similar at work, which means using a common colour scheme for our editor and terminal, plus the same shell configuration.

The team's put together a simple .zshrc for us all to use, but I have my own configuration that I'd like to keep, and only use the simple one for screencasts when using a specific profile.

To use a custom .zshrc for a single profile in iTerm2, edit your profile and set the command field to the following (replacing .kong-screencast/zsh with the path to the folder containing your .zshrc file):

env ZDOTDIR=.kong-screencast/zsh /bin/zsh

The ZDOTDIR allows you to specify an alternative load path for zsh to read it's config from. You can't set environment variables in iTerm2, but the env utility lets us set any variables we like and then spawn another process (in this case, zsh)

With this config, I can keep my own .zshrc in place and run a custom configuration any time I need by launching the custom profile