Browse code

add pip completion and plugin

Daniel Schauenberg authored on 01/09/2010 at 11:21:11
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,46 @@
0
+#compdef pip
1
+#autoload
2
+
3
+# pip zsh completion, based on homebrew completion
4
+
5
+_pip_installed() {
6
+  installed_pkgs=(`pip freeze`)
7
+}
8
+
9
+local -a _1st_arguments
10
+_1st_arguments=(
11
+  'bundle:Create pybundles (archives containing multiple packages)'
12
+  'freeze:Output all currently installed packages (exact versions) to stdout'
13
+  'help:Show available commands'
14
+  'install:Install packages'
15
+  'search:Search PyPI'
16
+  'uninstall:Uninstall packages'
17
+  'unzip:Unzip individual packages'
18
+  'zip:Zip individual packages'
19
+)
20
+
21
+local expl
22
+local -a pkgs installed_pkgs
23
+
24
+_arguments \
25
+  '(--version)--version[Show version number of program and exit]' \
26
+  '(-v --verbose)'{-v,--verbose}'[Give more output]' \
27
+  '(-q --quiet)'{-q,--quiet}'[Give less output]' \
28
+  '(-h --help)'{-h,--help}'[Show help]' \
29
+  '*:: :->subcmds' && return 0
30
+
31
+if (( CURRENT == 1 )); then
32
+  _describe -t commands "pip subcommand" _1st_arguments
33
+  return
34
+fi
35
+
36
+case "$words[1]" in
37
+  list)
38
+      if [[ "$state" == forms ]]; then
39
+        _pip_installed
40
+        _requested installed_pkgs expl 'installed packages' compadd -a installed_pkgs
41
+      fi ;;
42
+  uninstall)
43
+    _pip_installed
44
+    _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
45
+esac
0 46
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+# add brew completion function to path
1
+fpath=($ZSH/functions/pip $fpath)
2
+autoload -U compinit
3
+compinit -i