2

I'm using zsh with prezto. The startup prompt is extremely slow. I use iTerm2 on Mac.

enter image description here

Here is my ~/.zshrc

#
# Executes commands at the start of an interactive session.
#
# Authors:
#   Sorin Ionescu <sorin.ionescu@gmail.com>
#

# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi


# Customize to your needs.
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

autoload -U +X bashcompinit && bashcompinit

Here is my ~/.zpreztorc

zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'ssh' \
  'completion' \
  'homebrew' \
  'node' \
  'osx' \
  'git' \
  'syntax-highlighting' \
  'history-substring-search' \
  'autosuggestions' \
  'prompt'

I have a hunch that the order of the modules would make a difference ? Furthermore, I have also tried removing some modules but that didn't seem to make a difference either.

tsaebeht
  • 1,570
  • 5
  • 18
  • 32

1 Answers1

2

I had a similar issue and the way I fixed the problem was:

Add this line to the very top of my .zshrc file:

zmodload zsh/zprof

That includes zsh profiling module, zprof, at the beginning of the file.

Then opened a new terminal session (so the changes would take place and zprof was loaded) and executed

zprof

It gave me a report of where did my system spent most of its time.

In my particular case it was executing nvm-related tasks. I suspect the OP had a similar issue, since they were loading the node module.

Since I rarely use node these days I just uninstalled everything Node-related, including nvm, and I also removed all the node and nvm related lines I had on my .zshrc.

This did it for me, so I commented out the zmodload zsh/zprof line from .zshrc.

While googling for this people who actually need to use Node on a daily basis have come up with other solutions.

For example here: https://xcv58.me/if-your-zsh-starts-very-slow-cb1434ea16bd

This person created a zprezto module called zsh-lazy-load (repo) which can be used to defer loading nvm until it's needed.

Disclaimer: I have not tried zsh-lazy-load myself so I cannot fully recommend it; just added it in case it was useful for anyone.

kikito
  • 51,734
  • 32
  • 149
  • 189