Love reading about this stuff, as I’m obsessive. On my current machine, I just measured it at about 60ms, if I’m reading it right:
❯ time zsh -i -c "print -n"
zsh -i -c "print -n" 0.04s user 0.01s system 95% cpu 0.060 total
As nice as all the community-driven zsh frameworks are, most of them don’t respect startup time at all. I’d rather only add in what I absolutely need (which turns out to be not much) and perceive my machine to be faster.
This is very interesting, thanks!
Another one of my favorite things to do, in a similar vein, is to profile vim’s start up time using the --startuptime parameter to find plugins that should be autoloaded but are not. This answer on StackOverflow also helps in understanding the output for vim.
For me the biggest offender is one of the .ohmyzsh scripts that i’m toying with right now. It supposed to show the git-branch in the prompt but for large repos with lots of history this is unbearably slow (even on ssd). Takes ~1second.
You should see what it’s doing. I have the same thing but customized it for speed. It supports hg and git, only executes when in certain subdirectories.
if [$(pwd | grep "src|work|lib") != ""]; then
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/±\1/' | tr "\n" ' '
hg branch 2> /dev/null | sed -e 's/\(.*\)/☿\1 /'
edit: that’s for bash btw, not sure if zsh requires edits.
ZSH has the built-in vcs_info.
Here’s a conf example and the result.