Hacker News new | ask | show | jobs
by dezzadk 1315 days ago
This tip beats all tips https://asciinema.org/a/274255

You can move the line below your bindkey defs so you still have keys.

1 comments

Excerpt from script comments:

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!

True, however at some point you have plugins that take near 1s to load like syntax highlighting and its just not possible to reduce that to 100ms
I just start typing command before prompt shows...