From b8eea8eedb992efd6da87e2b3f81b29cf7c8097d Mon Sep 17 00:00:00 2001 From: Oscaner Miao Date: Wed, 13 Sep 2023 10:33:51 +0800 Subject: [PATCH] #85: fix _zsh_nvm_completion on macos homebrew. --- zsh-nvm.plugin.zsh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index f4f56f3..4d0bf07 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -74,7 +74,13 @@ _zsh_nvm_load() { _zsh_nvm_completion() { # Add provided nvm completion - [[ -r $NVM_DIR/bash_completion ]] && source $NVM_DIR/bash_completion + # default + if [[ -f "$NVM_DIR/bash_completion" ]]; then + source "$NVM_DIR/bash_completion" + # homebrew + elif _zsh_nvm_has brew && [[ -f "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ]]; then + source "$(brew --prefix nvm)/etc/bash_completion.d/nvm" + fi } _zsh_nvm_lazy_load() { @@ -218,7 +224,7 @@ if [[ "$ZSH_NVM_NO_LOAD" != true ]]; then # Enable completion [[ "$NVM_COMPLETION" == true ]] && _zsh_nvm_completion - + # Auto use nvm on chpwd [[ "$NVM_AUTO_USE" == true ]] && add-zsh-hook chpwd _zsh_nvm_auto_use && _zsh_nvm_auto_use fi