At some point, starting a zsh (I’m using iTerm2 here) took almost 10 seconds on macOS 11 Big Sur. This only happened the first time when I opened iTerm2 after a reboot. After mentally going through all the software changes I had done to my rig, I was pretty sure this happened right after installing Xcode. After some debugging in the oh-my-zsh code I found the culprit: it’s related to Apple’s git version which comes with Xcode. After installing the Homebrew version of git, the delay no longer occurred. It’s important though that the Homebrew git binary is found first when calling git from the command line.
However, a few days later, the initial delay came back again. This time, the culprit was nvm (Nodejs version manager) or more specifically, adding the nvm variables to my ~/.zshrc. I’ve found a snippet that lazy loads the nvm.sh in ~/.zshrc. Check out this Gist:
The two workarounds combined drastically reduce (oh-my-)zsh loading times on my Mac. Make sure to remove an existing nvm init variables from ~/.zshrc before applying the lazy loading code.