Why is oh-my-zsh so slow?

I decided to try figuring out why it takes 1-3 seconds to open a new Terminal.app window/tab and tmux window/pane with (oh-my-)zsh.

Here’s all the crap I tried:

Deleted ASL logs.

– Disabled all one of the plugins I used (git).

– Switched to a “leaner” theme (lambda).

– Downloaded a newer version of zsh and made Terminal.app use “/usr/local/bin/zsh -i” instead of the default login shell.

– Completely gave up on oh-my-zsh and switched to prezto

Once I switch to Prezto, zsh was pretty quick. Until I copied the junk in my old .zshrc file to my brand new .zshrc file.

And then I noticed something. Four instances of command substitution. Three of them from homebrew (autojump, coreutils, php56) and rbenv.

Out of curiosity, I replaced the command substitutions with the raw output, including the output of eval "$(rbenv init -)".

2016-07-27 edit: I realized a couple of days ago that this is not good to do. rbenv will not be loaded without the eval command.

And look at that. Now oh-my-zsh is fast! I even re-enabled the git plugin. Still fast.

Conclusion: Don’t put a bunch of $(command-to-find-a-path) in your .zshrc file. Just use the actual path. It may shave 1-2 seconds off of your zsh startup time.