f9282283822771a7f471547569de481a66a70b0f

Author
Sorin Ionescu <sorin.ionescu@gmail.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Added npm plugin.

Diff

 1diff --git a/plugins/npm/_npm b/plugins/npm/_npm
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..24b536188e08a12e9422fef49c16409b478d329c
 4--- /dev/null
 5+++ b/plugins/npm/_npm
 6@@ -0,0 +1,19 @@
 7+#compdef npm
 8+
 9+# Node Package Manager 0.3.15 completion, letting npm do all the completion work
10+
11+_npm() {
12+  compadd -- $(_npm_complete $words)
13+}
14+
15+# We want to show all errors of any substance, but never the "npm (not )ok" one.
16+# (Also doesn't consider "ERR! no match found" worth breaking the terminal for.)
17+_npm_complete() {
18+  local ask_npm
19+  ask_npm=(npm completion --color false --loglevel error -- $@)
20+  { _call_program npm $ask_npm 2>&1 >&3 \
21+  | egrep -v '^(npm (not |)ok|ERR! no match found)$' >&2; \
22+  } 3>&1
23+}
24+
25+_npm "$@"
26diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
27new file mode 100644
28index 0000000000000000000000000000000000000000..826f0f7b00b89019e562bf21e178d7d5dcd53a63
29--- /dev/null
30+++ b/plugins/npm/npm.plugin.zsh
31@@ -0,0 +1,4 @@
32+# add npm completion function to path
33+fpath=($ZSH/plugins/npm $fpath)
34+autoload -U compinit
35+compinit -i