cef6dcd98bb42c5ca2613bbbef12dd384ec8e33a

Author
Daniel Schauenberg <d@unwiredcouch.com>
Committer
Daniel Schauenberg <d@unwiredcouch.com>
Date

Message

Merge branch 'pip_plugin'

Diff

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