mirror of
https://github.com/lukechilds/zsh-nvm.git
synced 2025-06-05 11:56:28 +08:00
Add support for NVM_SILENT environment variable #91
This commit is contained in:
parent
745291dcf2
commit
cc8e1a05f1
11
README.md
11
README.md
@ -149,6 +149,17 @@ export NVM_AUTO_USE=true
|
|||||||
antigen bundle lukechilds/zsh-nvm
|
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
|
## Installation
|
||||||
|
|
||||||
### Using [Antigen](https://github.com/zsh-users/antigen)
|
### Using [Antigen](https://github.com/zsh-users/antigen)
|
||||||
|
@ -176,12 +176,20 @@ _zsh_nvm_auto_use() {
|
|||||||
if [[ "$nvmrc_node_version" = "N/A" ]]; then
|
if [[ "$nvmrc_node_version" = "N/A" ]]; then
|
||||||
nvm install && export NVM_AUTO_USE_ACTIVE=true
|
nvm install && export NVM_AUTO_USE_ACTIVE=true
|
||||||
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
|
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
|
||||||
|
if [[ "$NVM_SILENT" == true ]]; then
|
||||||
|
nvm use --silent && export NVM_AUTO_USE_ACTIVE=true
|
||||||
|
else
|
||||||
nvm use && export NVM_AUTO_USE_ACTIVE=true
|
nvm use && export NVM_AUTO_USE_ACTIVE=true
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
elif [[ "$node_version" != "$(nvm version default)" ]] && [[ "$NVM_AUTO_USE_ACTIVE" = true ]]; then
|
elif [[ "$node_version" != "$(nvm version default)" ]] && [[ "$NVM_AUTO_USE_ACTIVE" = true ]]; then
|
||||||
|
if [[ "$NVM_SILENT" == true ]]; then
|
||||||
|
nvm use default --silent
|
||||||
|
else
|
||||||
echo "Reverting to nvm default version"
|
echo "Reverting to nvm default version"
|
||||||
nvm use default
|
nvm use default
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_zsh_nvm_install_wrapper() {
|
_zsh_nvm_install_wrapper() {
|
||||||
|
Loading…
Reference in New Issue
Block a user