-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
OS: Mac OSbugsOh no, something's broken :-(Oh no, something's broken :-(performanceThis relates to anything regarding the speed of using nvm.This relates to anything regarding the speed of using nvm.shell: bash/sh
Description
I start up a lot of terminal windows on my Mac and for some reason the commands
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
that I had in my .bashrc would sometimes take a noticeable and annoying amount of time to run. (Maybe as long as 2 seconds.) My solution was to setup environment variables like NVM_DIR as usual but to fully defer all other nvm setup until first use by adding these definitions to my .bash_profile script:
function _install_nvm() {
unset -f nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This sets up nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # load nvm bash_completion
nvm "$@"
}
function nvm() {
_install_nvm "$@"
}
I am not familiar enough with other shells to say how portable that is (I am using GNU bash), but I suggest you at least add it to the documentation (if not the install script) so that people can have an easy way to install deferred setup of nvm that is truly deferred.
jcsahnwaldt, dreamer-nitj, tmpm697, chmac, mcouthon and 11 morechmac
Metadata
Metadata
Assignees
Labels
OS: Mac OSbugsOh no, something's broken :-(Oh no, something's broken :-(performanceThis relates to anything regarding the speed of using nvm.This relates to anything regarding the speed of using nvm.shell: bash/sh