Browse code

Added npm plugin.

Sorin Ionescu authored on 20/03/2011 at 20:29:00
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+#compdef npm
1
+
2
+# Node Package Manager 0.3.15 completion, letting npm do all the completion work
3
+
4
+_npm() {
5
+  compadd -- $(_npm_complete $words)
6
+}
7
+
8
+# We want to show all errors of any substance, but never the "npm (not )ok" one.
9
+# (Also doesn't consider "ERR! no match found" worth breaking the terminal for.)
10
+_npm_complete() {
11
+  local ask_npm
12
+  ask_npm=(npm completion --color false --loglevel error -- $@)
13
+  { _call_program npm $ask_npm 2>&1 >&3 \
14
+  | egrep -v '^(npm (not |)ok|ERR! no match found)$' >&2; \
15
+  } 3>&1
16
+}
17
+
18
+_npm "$@"
0 19
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+# add npm completion function to path
1
+fpath=($ZSH/plugins/npm $fpath)
2
+autoload -U compinit
3
+compinit -i