-
-
Notifications
You must be signed in to change notification settings - Fork 112
-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NVM_AUTO_USE doesn't work with NVM_LAZY_LOAD until too late #72
Comments
I was having the same issue, and I thought I would share my workaround in case someone might find it useful. Basically, I declare a directory where, if I open a shell in it or it's sub-dirs, nvm is loaded. # <-------- .zshrc -------->
# <------- export zsh-nvm variables **above** ----->
# Declare the directory(s) where you code
export NVM_LAZY_AUTO_DIR=("$HOME/code")
activate_nvm() {
# checking dir in path, and if node is a shell function (not loaded)
if [[ $PWD =~ $NVM_LAZY_AUTO_DIR && "$(type node)" = *'a shell function'* ]]; then
print 'Activating nvm...'
# trigger loading
node --version
# cd into same dir to activate auto_use
cd $PWD
fi
}
# use this function if LAZY_LOAD is true
if [[ ( $NVM_LAZY_LOAD ) ]]; then
precmd_functions+=(activate_nvm)
fi
# <-------- source zsh-nvm **below** ---------> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_zsh_nvm_auto_use
will return early ifnvm_find_nvmrc
is not found, which will be the case when lazy loading.Would you consider including a copy of
nvm_find_nvmrc
inside your code if lazy loading, so that auto use can work as intended, beforenvm
,node
, etc are run for the first time?The text was updated successfully, but these errors were encountered: