mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-11 06:41:50 +00:00
Update example bash script to use nvm use on shell open
This commit is contained in:
parent
8093dbeacd
commit
b93a27ed03
10
README.md
10
README.md
@ -458,8 +458,12 @@ find-up () {
|
|||||||
echo "$path"
|
echo "$path"
|
||||||
}
|
}
|
||||||
|
|
||||||
cdnvm(){
|
cdnvm() {
|
||||||
cd "$@";
|
cd "$@";
|
||||||
|
nvmUse
|
||||||
|
}
|
||||||
|
|
||||||
|
nvmUse() {
|
||||||
nvm_path=$(find-up .nvmrc | tr -d '[:space:]')
|
nvm_path=$(find-up .nvmrc | tr -d '[:space:]')
|
||||||
|
|
||||||
# If there are no .nvmrc file, use the default nvm version
|
# If there are no .nvmrc file, use the default nvm version
|
||||||
@ -500,11 +504,15 @@ cdnvm(){
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
alias cd='cdnvm'
|
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.
|
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
|
#### zsh
|
||||||
|
|
||||||
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
|
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
|
||||||
|
Loading…
Reference in New Issue
Block a user