GNU/Linux ◆ xterm-256color ◆ zsh 2508 views

The screencast starts with the following docker command:

docker run -e LANG=C.UTF-8 -e TERM -it --rm debian:buster bash -uec '
  apt update && apt install -y curl git zsh sudo nano
  useradd -ms /bin/zsh me
  sudo -u me sh -c "$(curl -fsSL \
    https://raw.githubusercontent.com/zdharma/zplugin/master/doc/install.sh)"
  >>~me/.zshrc echo "zplugin ice atload\"source config/p10k-pure.zsh\" lucid
zplugin light romkatv/powerlevel10k
# source ~/.zplugin/plugins/romkatv---powerlevel10k/config/p10k-pure.zsh
# source ~/.zplugin/plugins/romkatv---powerlevel10k/powerlevel10k.zsh-theme"
  exec su - me'

It installs zsh and zplugin on Debian and logs in as a user with the following ~/.zshrc:

### Added by Zplugin's installer
source '/home/me/.zplugin/bin/zplugin.zsh'
autoload -Uz _zplugin
(( ${+_comps} )) && _comps[zplugin]=_zplugin
### End of Zplugin installer's chunk

zplugin ice atload"source config/p10k-pure.zsh" lucid
zplugin light romkatv/powerlevel10k

# source ~/.zplugin/plugins/romkatv---powerlevel10k/config/p10k-pure.zsh
# source ~/.zplugin/plugins/romkatv---powerlevel10k/powerlevel10k.zsh-theme

Note that powerlevel10k and its config are loaded with zplugin.

After logging in, the current directory is changed to ~/.zplugin/plugins/romkatv---powerlevel10k because it’s more interesting to observe what happens next if you are in a Git repository. You can see that true is instant while exec zsh is almost instant.

The following command is used to measure zsh startup latency:

time ( repeat 100 zsh -is <<< '' )

It repeatedly starts interacive zsh sessions and exits them once the first prompt renders. The command takes 5.115s (51ms per run).

Then ~/.zshrc is edited so that powerlevel10k and its config are sourced directly, without zplugin. Here’s the new ~/.zshrc.

source ~/.zplugin/plugins/romkatv---powerlevel10k/config/p10k-pure.zsh
source ~/.zplugin/plugins/romkatv---powerlevel10k/powerlevel10k.zsh-theme

After starting a new zsh session everything proceeds as before. This time the benchmark completes in 4.016s (40ms per run).