加快 zsh 启动时间

加快 zsh 启动时间

我使用的是 MacOS 10.11。当我在 Iterm2 上打开新选项卡时,需要将近 2 秒钟才能出现提示。所以我猜我在.zshrc/ .bash_profile/中有一些.bashrc需要花费一些时间加载的东西。这些文件如下:

.zshrc

export ZSH=/Users/ThomasDehaeze/.oh-my-zsh
ZSH_THEME="cobalt2"
plugins=(brew extract z sudo zsh-syntax-highlighting colored-man-pages web-search)
export PATH="$PATH:/Users/ThomasDehaeze/.rvm/gems/ruby-2.2.1/bin:/Users/ThomasDehaeze/.rvm/gems/ruby-2.2.1@global/bin:/Users/ThomasDehaeze/.rvm/rubies/ruby-2.2.1/bin:/usr/local/share/npm/bin:/usr/local/share/python:/Users/ThomasDehaeze/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ThomasDehaeze/.rvm/bin:/Users/ThomasDehaeze/miniconda3/bin:/Users/ThomasDehaeze/bin"

export ZSH_THEME_GIT_PROMPT_STASHED
export PATH=/Library/TeX/texbin:$PATH
export PATH=/opt/apache-maven-3.3.9/bin:$PATH
export VISUAL=vim
export EDITOR="$VISUAL"

source $ZSH/oh-my-zsh.sh
source ~/.git-flow-completion.zsh

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

export PATH="/usr/local/sbin:$PATH"

export NVM_DIR="/Users/ThomasDehaeze/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

.bash_profile

PATH=/usr/local/bin:$PATH
PATH=$HOME/bin:$PATH
export PATH
for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do
  [ -r "$file" ] && source "$file"
done
unset file
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
source /usr/local/opt/autoenv/activate.sh

.bashrc

export PIP_REQUIRE_VIRTUALENV=true
export PATH="$PATH:$HOME/.rvm/bin"

我猜是因为 mvn/npm 加载了太多次。你能确认一下吗?我应该包含什么路径以及在哪里?

非常感谢 :)

答案1

尝试这个命令:nvm unalias default。然后重新启动你的终端。

警告:现在您必须nvm use <version>在使用节点之前启动。

来源:https://github.com/creationix/nvm/issues/703#issuecomment-145917599

相关内容