Update example bash script to use nvm use on shell open

This commit is contained in:
GARY PARKER 2020-02-21 08:26:24 -05:00
parent 8093dbeacd
commit b93a27ed03

View File

@ -458,8 +458,12 @@ find-up () {
echo "$path"
}
cdnvm(){
cdnvm() {
cd "$@";
nvmUse
}
nvmUse() {
nvm_path=$(find-up .nvmrc | tr -d '[:space:]')
# If there are no .nvmrc file, use the default nvm version
@ -500,11 +504,15 @@ cdnvm(){
fi
fi
}
alias cd='cdnvm'
nvmUse
```
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
It will also call `nvm use` when a new terminal window is opened (e.g. opening a terminal in your IDE).
#### zsh
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file