diff --git a/zsh-better-npm-completion.plugin.zsh b/zsh-better-npm-completion.plugin.zsh index f5d0ff4..14a1a60 100644 --- a/zsh-better-npm-completion.plugin.zsh +++ b/zsh-better-npm-completion.plugin.zsh @@ -2,6 +2,10 @@ _zbnc_npm_command() { echo "${words[2]}" } +_zbnc_npm_command_arg() { + echo "${words[3]}" +} + _zbnc_no_of_npm_args() { echo "$#words" } @@ -66,6 +70,9 @@ _zbnc_npm_install_completion() { _zbnc_npm_uninstall_completion() { + # Use default npm completion to recommend global modules + [[ "$(_zbnc_npm_command_arg)" = "-g" ]] || [[ "$(_zbnc_npm_command_arg)" = "--global" ]] && return + # Look for a package.json file local package_json="$(_zbnc_recursively_look_for package.json)"