This doesn't actually make your zsh start instantly, hence the reference to the "one weird trick" advertisement. It does, however, make it feel like zsh is loading faster. Or, put it another way, your original zsh wasn't so slow to load, but you thought it was slow. Now you see that it was pretty fast all along.
Here's how it work. To make your zsh "start instantly" all you need to do is print your prompt immediately when zsh starts, before doing anything else. At the top of ~/.zshrc is a good place for this. If your prompt takes a long time to initialize, print something that looks close enough. Then, while the rest of ~/.zshrc is evaluated and precmd hooks are run, all keyboard input simply gets buffered. Once initialization is complete, clear the screen and allow the real prompt be printed where the "loading" prompt was before. With the real prompt in place, all buffered keyboard input is processed by zle.
It's a bit gimmicky but it does reduce the perceived ZSH startup latency by a lot. To make it more interesting, add `sleep 1` at the bottom of zsh and try opening a new tab in your terminal. It's still instant!
This doesn't actually make your zsh start instantly, hence the reference to the "one weird trick" advertisement. It does, however, make it feel like zsh is loading faster. Or, put it another way, your original zsh wasn't so slow to load, but you thought it was slow. Now you see that it was pretty fast all along.
Here's how it work. To make your zsh "start instantly" all you need to do is print your prompt immediately when zsh starts, before doing anything else. At the top of ~/.zshrc is a good place for this. If your prompt takes a long time to initialize, print something that looks close enough. Then, while the rest of ~/.zshrc is evaluated and precmd hooks are run, all keyboard input simply gets buffered. Once initialization is complete, clear the screen and allow the real prompt be printed where the "loading" prompt was before. With the real prompt in place, all buffered keyboard input is processed by zle.
It's a bit gimmicky but it does reduce the perceived ZSH startup latency by a lot. To make it more interesting, add `sleep 1` at the bottom of zsh and try opening a new tab in your terminal. It's still instant!