我正在使用zsh和prezto。启动提示符非常慢。我在Mac上使用iTerm2。

这是我的~/.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这是我的~/.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'我有预感,模块的顺序会有所不同?此外,我还尝试删除了一些模块,但似乎也没有什么不同。
发布于 2020-10-14 19:09:13
我也遇到过类似的问题,我解决这个问题的方法是:
将下面这一行添加到我的.zshrc文件的最顶部:
zmodload zsh/zprof这包括文件开头的zsh概要分析模块zprof。
然后打开一个新的终端会话(这样更改就会发生并加载zprof )并执行
zprof它为我提供了一份报告,说明我的系统大部分时间都花在哪里。
在我的特殊情况下,它执行的是nvm-related任务。我怀疑OP也有类似的问题,因为他们正在加载node模块。
这为我做了准备,所以我注释掉了.zshrc中的zmodload zsh/zprof行。
在谷歌搜索的时候,那些真正需要每天使用Node的人已经想出了其他的解决方案。
例如:https://xcv58.me/if-your-zsh-starts-very-slow-cb1434ea16bd
这个人创建了一个名为zsh-lazy-load (repo)的zprezto模块,可用于defer loading nvm until it's needed。
免责声明:我自己没有尝试过zsh-lazy-load,所以我不能完全推荐它;只是为了防止它对任何人有用而添加了它。
https://stackoverflow.com/questions/54434933
复制相似问题