Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NVM_SILENT environment variable #91 #102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,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

### Using [Antigen](https://github.com/zsh-users/antigen)
Expand Down
14 changes: 11 additions & 3 deletions zsh-nvm.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,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
}

Expand Down