Add support for NVM_SILENT env var

This commit is contained in:
Vyacheslav Shcherbinin 2023-10-19 19:18:52 +07:00
parent ee2e1b5c5f
commit 3c7315c8e4
2 changed files with 22 additions and 3 deletions

View File

@ -145,6 +145,17 @@ export NVM_AUTO_USE=true
antigen bundle lukechilds/zsh-nvm
```
### Silent switching
If you use `Auto use` feature of this plugin with a theme that supports node version printing, you may want to disable some messages that nvm prints when it switches between versions. You can disable it by exporting the `NVM_SILENT` environment variable and setting it to `true`.
For example, if you are using antigen, you would put the following in your `.zshrc`:
```shell
export NVM_SILENT=true
antigen bundle lukechilds/zsh-nvm
```
## Installation
### As an [Oh My ZSH!](https://github.com/robbyrussell/oh-my-zsh) custom plugin

View File

@ -182,11 +182,19 @@ _zsh_nvm_auto_use() {
if [[ "$nvmrc_node_version" = "N/A" ]]; then
nvm install && export NVM_AUTO_USE_ACTIVE=true
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
nvm use && export NVM_AUTO_USE_ACTIVE=true
if [[ "$NVM_SILENT" == true ]]; then
nvm use --silent && export NVM_AUTO_USE_ACTIVE=true
else
nvm use && export NVM_AUTO_USE_ACTIVE=true
fi
fi
elif [[ "$node_version" != "$(nvm version default)" ]] && [[ "$NVM_AUTO_USE_ACTIVE" = true ]]; then
echo "Reverting to nvm default version"
nvm use default
if [[ "$NVM_SILENT" == true ]]; then
nvm use default --silent
else
echo "Reverting to nvm default version"
nvm use default
fi
fi
}