all repos — dotfiles @ e98c19dac08ae83a4050665fc0df1f077bde1eb8

my *nix dotfiles

fix(nvm): fix slow terminal initialization
icyphox icyph0x@protonmail.com
Sat, 24 Feb 2018 17:09:02 +0530
commit

e98c19dac08ae83a4050665fc0df1f077bde1eb8

parent

48d317a422eda3c3ec9d4558c0ef37d07d6c3ff4

1 files changed, 18 insertions(+), 3 deletions(-)

jump to
M zsh/.zshrczsh/.zshrc

@@ -51,6 +51,21 @@ eval $(gnome-keyring-daemon --start)

export SSH_AUTH_SOCK fi -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +#export NVM_DIR="$HOME/.nvm" +#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +# Defer initialization of nvm until nvm, node or a node-dependent command is +# run. Ensure this block is only run once if .bashrc gets sourced multiple times +# by checking whether __init_nvm is a function. +if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type __init_nvm)" = function ]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" + declare -a __node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack') + function __init_nvm() { + for i in "${__node_commands[@]}"; do unalias $i; done + . "$NVM_DIR"/nvm.sh + unset __node_commands + unset -f __init_nvm + } + for i in "${__node_commands[@]}"; do alias $i='__init_nvm && '$i; done +fi