diff --git a/exports b/exports index ac5ab77..6d9f679 100644 --- a/exports +++ b/exports @@ -14,10 +14,25 @@ export PATH=$HOME/.bin:/usr/local/bin:"$(brew --prefix openssl)/bin":"$(brew --p export CDPATH=$CDPATH:~/Code # nvm -if [ -s "$HOME/.nvm" ]; then +# defer loading until needed for faster shell startup +declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`) + +NODE_GLOBALS+=("node") +NODE_GLOBALS+=("nvm") + +load_nvm () { export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -fi + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" +} + +for cmd in "${NODE_GLOBALS[@]}"; do + eval "${cmd}(){ unset -f ${NODE_GLOBALS}; load_nvm; ${cmd} \$@ }" +done +# ---- +# if [ -s "$HOME/.nvm" ]; then +# export NVM_DIR="$HOME/.nvm" +# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +# fi # pip should only run if there is a virtualenv currently activated #export PIP_REQUIRE_VIRTUALENV=true diff --git a/zshrc b/zshrc index f52149e..6ba8562 100644 --- a/zshrc +++ b/zshrc @@ -1,3 +1,5 @@ +# zmodload zsh/zprof + # https://github.com/sindresorhus/pure autoload -U promptinit; promptinit prompt pure @@ -8,6 +10,13 @@ DISABLE_AUTO_TITLE="true" ENABLE_CORRECTION="true" HIST_STAMPS="yyyy-mm-dd" +# https://carlosbecker.com/posts/speeding-up-zsh/ +autoload -Uz compinit +for dump in ~/.zcompdump(N.mh+24); do + compinit +done +compinit -C + # Oh My Zsh export ZSH="/Users/m/.oh-my-zsh" ZSH_THEME="" @@ -17,4 +26,6 @@ source $ZSH/oh-my-zsh.sh # User configuration source ~/.exports source ~/.aliases -source ~/.private \ No newline at end of file +source ~/.private + +# zprof \ No newline at end of file