summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo <carlosalag@protonmail.com>2022-12-01 19:44:48 +0100
committerGitHub <noreply@github.com>2022-12-01 19:44:48 +0100
commit64bc22aee4d32eb64ee918fc9e63318b68979070 (patch)
treeb9ec5e4e662e0ed022652578e7e148c330fbf509
parenta051eb04b88cb0a876d1f3d68559d228a14dccf0 (diff)
downloadzsh-64bc22aee4d32eb64ee918fc9e63318b68979070.tar.gz
zsh-64bc22aee4d32eb64ee918fc9e63318b68979070.tar.bz2
zsh-64bc22aee4d32eb64ee918fc9e63318b68979070.zip
feat(nvm): add `silent-autoload` setting (#11363)
Co-authored-by: MichaƂ Regulski <regulskimichal@outlook.com> Closes #10942
-rw-r--r--plugins/nvm/README.md10
-rw-r--r--plugins/nvm/nvm.plugin.zsh12
2 files changed, 16 insertions, 6 deletions
diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
index 4c6312e6e..d3fd980be 100644
--- a/plugins/nvm/README.md
+++ b/plugins/nvm/README.md
@@ -48,5 +48,13 @@ If set, the plugin will automatically load a node version when if finds a
version to load. This can be done, similar as previous options, adding:
```zsh
-zstyle ':omz:plugins:nvm' autoload true
+zstyle ':omz:plugins:nvm' autoload yes
```
+
+To remove the output generated by NVM when autoloading, you can set the following option:
+
+```zsh
+zstyle ':omz:plugins:nvm' silent-autoload yes
+```
+
+Note: _this will not remove regular `nvm` output_
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index ec583cc2d..c5799c88e 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -24,11 +24,11 @@ if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then
# Nicely print the list in the style `var1, var2 and var3`
echo "${fg[yellow]}[nvm plugin] Variable-style settings are deprecated. Instead of ${(j:, :)used_vars[1,-2]}${used_vars[-2]+ and }${used_vars[-1]}, use:\n"
if (( $+NVM_AUTOLOAD )); then
- echo " zstyle ':omz:plugins:nvm' autoload true"
+ echo " zstyle ':omz:plugins:nvm' autoload yes"
zstyle ':omz:plugins:nvm' autoload yes
fi
if (( $+NVM_LAZY )); then
- echo " zstyle ':omz:plugins:nvm' lazy true"
+ echo " zstyle ':omz:plugins:nvm' lazy yes"
zstyle ':omz:plugins:nvm' lazy yes
fi
if (( $+NVM_LAZY_CMD )); then
@@ -61,9 +61,11 @@ fi
# Autoload nvm when finding a .nvmrc file in the current directory
# Adapted from: https://github.com/nvm-sh/nvm#zsh
if zstyle -t ':omz:plugins:nvm' autoload; then
- load-nvmrc() {
+ function load-nvmrc {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
+ local nvm_silent=""
+ zstyle -t ':omz:plugins:nvm' silent-autoload && _nvm_silent="--silent"
if [[ -n "$nvmrc_path" ]]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
@@ -71,11 +73,11 @@ if zstyle -t ':omz:plugins:nvm' autoload; then
if [[ "$nvmrc_node_version" = "N/A" ]]; then
nvm install
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
- nvm use
+ nvm use $nvm_silent
fi
elif [[ "$node_version" != "$(nvm version default)" ]]; then
echo "Reverting to nvm default version"
- nvm use default
+ nvm use default $nvm_silent
fi
}