Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use new zsh completion, if available

  • Loading branch information...
commit 3cc603c79b3090f32ee18e0efa5c13361f69026e 1 parent 2d35cc5
@jmcantrell jmcantrell authored isaacs committed
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/utils/completion.sh
View
15 lib/utils/completion.sh
@@ -11,7 +11,7 @@ COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
export COMP_WORDBREAKS
-if complete &>/dev/null; then
+if type complete &>/dev/null; then
_npm_completion () {
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
@@ -22,7 +22,18 @@ if complete &>/dev/null; then
IFS="$si"
}
complete -F _npm_completion npm
-elif compctl &>/dev/null; then
+elif type compdef &>/dev/null; then
+ _npm_completion() {
+ si=$IFS
+ compadd -- $(COMP_CWORD=$((CURRENT-1)) \
+ COMP_LINE=$BUFFER \
+ COMP_POINT=0 \
+ npm completion -- "${words[@]}" \
+ 2>/dev/null)
+ IFS=$si
+ }
+ compdef _npm_completion npm
+elif type compctl &>/dev/null; then
_npm_completion () {
local cword line point words si
read -Ac words
Please sign in to comment.
Something went wrong with that request. Please try again.