mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-11 14:51:49 +00:00
Merge pull request #1076 from ejinotti/master
[Docs] Improve zsh script in README
This commit is contained in:
commit
a551306275
@ -195,13 +195,18 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e
|
|||||||
`.nvmrc` file with a string telling nvm which node to `use`:
|
`.nvmrc` file with a string telling nvm which node to `use`:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
# place this after nvm initialization!
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
load-nvmrc() {
|
load-nvmrc() {
|
||||||
if [[ -f .nvmrc && -r .nvmrc ]]; then
|
if [[ -f .nvmrc && -r .nvmrc ]]; then
|
||||||
nvm use
|
nvm use
|
||||||
|
elif [[ $(nvm version) != $(nvm version default) ]]; then
|
||||||
|
echo "Reverting to nvm default version"
|
||||||
|
nvm use default
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
add-zsh-hook chpwd load-nvmrc
|
add-zsh-hook chpwd load-nvmrc
|
||||||
|
load-nvmrc
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
Loading…
Reference in New Issue
Block a user