1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-02-13 05:59:46 +08:00

Compare commits

..

No commits in common. "fc44c49cca9d5e499097392d3f42b1375d0253ba" and "a051eb04b88cb0a876d1f3d68559d228a14dccf0" have entirely different histories.

2 changed files with 7 additions and 17 deletions

View File

@ -48,13 +48,5 @@ 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: version to load. This can be done, similar as previous options, adding:
```zsh ```zsh
zstyle ':omz:plugins:nvm' autoload yes zstyle ':omz:plugins:nvm' autoload true
``` ```
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_

View File

@ -24,11 +24,11 @@ if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then
# Nicely print the list in the style `var1, var2 and var3` # 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" 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 if (( $+NVM_AUTOLOAD )); then
echo " zstyle ':omz:plugins:nvm' autoload yes" echo " zstyle ':omz:plugins:nvm' autoload true"
zstyle ':omz:plugins:nvm' autoload yes zstyle ':omz:plugins:nvm' autoload yes
fi fi
if (( $+NVM_LAZY )); then if (( $+NVM_LAZY )); then
echo " zstyle ':omz:plugins:nvm' lazy yes" echo " zstyle ':omz:plugins:nvm' lazy true"
zstyle ':omz:plugins:nvm' lazy yes zstyle ':omz:plugins:nvm' lazy yes
fi fi
if (( $+NVM_LAZY_CMD )); then if (( $+NVM_LAZY_CMD )); then
@ -61,23 +61,21 @@ fi
# Autoload nvm when finding a .nvmrc file in the current directory # Autoload nvm when finding a .nvmrc file in the current directory
# Adapted from: https://github.com/nvm-sh/nvm#zsh # Adapted from: https://github.com/nvm-sh/nvm#zsh
if zstyle -t ':omz:plugins:nvm' autoload; then if zstyle -t ':omz:plugins:nvm' autoload; then
function load-nvmrc { load-nvmrc() {
local node_version="$(nvm version)" local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)" local nvmrc_path="$(nvm_find_nvmrc)"
local nvm_silent=""
zstyle -t ':omz:plugins:nvm' silent-autoload && _nvm_silent="--silent"
if [[ -n "$nvmrc_path" ]]; then if [[ -n "$nvmrc_path" ]]; then
local nvmrc_node_version=$(nvm version $(cat "$nvmrc_path" | tr -dc '[:print:]')) local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [[ "$nvmrc_node_version" = "N/A" ]]; then if [[ "$nvmrc_node_version" = "N/A" ]]; then
nvm install nvm install
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
nvm use $nvm_silent nvm use
fi fi
elif [[ "$node_version" != "$(nvm version default)" ]]; then elif [[ "$node_version" != "$(nvm version default)" ]]; then
echo "Reverting to nvm default version" echo "Reverting to nvm default version"
nvm use default $nvm_silent nvm use default
fi fi
} }