42b0123427d2bdee0e3221d930bb48038c601932

Author
Max Persson <max@maxpersson.com>
Committer
Max Persson <max@maxpersson.com>
Date

Message

Added brute force package completin on install subcommand

Diff

 1diff --git a/plugins/pip/_pip b/plugins/pip/_pip
 2index b58010173a5028b0dc0db651f042e56df861d497..8c03d85192ee9932006aa78b440ed9a34ad2eea2 100644
 3--- a/plugins/pip/_pip
 4+++ b/plugins/pip/_pip
 5@@ -3,30 +3,39 @@
 6 
 7 # pip zsh completion, based on homebrew completion
 8 
 9+_pip_all() {
10+  all_pkgs=(`pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'`)
11+}
12+
13 _pip_installed() {
14-  installed_pkgs=(`pip freeze`)
15+  installed_pkgs=(`pip freeze | cut -d '=' -f 1`)
16 }
17 
18 local -a _1st_arguments
19 _1st_arguments=(
20-  'bundle:Create pybundles (archives containing multiple packages)'
21-  'freeze:Output all currently installed packages (exact versions) to stdout'
22-  'help:Show available commands'
23-  'install:Install packages'
24-  'search:Search PyPI'
25-  'uninstall:Uninstall packages'
26-  'unzip:Unzip individual packages'
27-  'zip:Zip individual packages'
28+  'bundle:create pybundles (archives containing multiple packages)'
29+  'freeze:output all currently installed packages (exact versions) to stdout'
30+  'help:show available commands'
31+  'install:install packages'
32+  'search:search PyPI'
33+  'uninstall:uninstall packages'
34+  'unzip:unzip individual packages'
35+  'zip:zip individual packages'
36 )
37 
38 local expl
39-local -a pkgs installed_pkgs
40+local -a all_pkgs installed_pkgs
41 
42 _arguments \
43-  '(--version)--version[Show version number of program and exit]' \
44-  '(-v --verbose)'{-v,--verbose}'[Give more output]' \
45-  '(-q --quiet)'{-q,--quiet}'[Give less output]' \
46-  '(-h --help)'{-h,--help}'[Show help]' \
47+  '(--version)--version[show version number of program and exit]' \
48+  '(-h --help)'{-h,--help}'[show help]' \
49+  '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \
50+  '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
51+  '(-v --verbose)'{-v,--verbose}'[give more output]' \
52+  '(-q --quiet)'{-q,--quiet}'[give less output]' \
53+  '(--log)--log[log file location]' \
54+  '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
55+  '(--timeout)--timeout[socket timeout (default 15s)]' \
56   '*:: :->subcmds' && return 0
57 
58 if (( CURRENT == 1 )); then
59@@ -35,10 +44,25 @@ if (( CURRENT == 1 )); then
60 fi
61 
62 case "$words[1]" in
63-  list)
64-      if [[ "$state" == forms ]]; then
65-        _pip_installed
66-        _requested installed_pkgs expl 'installed packages' compadd -a installed_pkgs
67+  search)
68+    _arguments \
69+      '(--index)--index[base URL of Python Package Index]' ;;
70+  freeze)
71+    _arguments \
72+      '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
73+  install)
74+  	_arguments \
75+      '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
76+      '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
77+      '(--no-deps --no-dependencies)'{--no-deps,--no-dependencies}'[iIgnore package dependencies]' \
78+      '(--no-install)--no-install[only download packages]' \
79+      '(--no-download)--no-download[only install downloaded packages]' \
80+      '(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
81+      '1: :->packages' &&  return 0
82+     
83+      if [[ "$state" == packages ]]; then
84+        _pip_all
85+        _wanted all_pkgs expl 'packages' compadd -a all_pkgs
86       fi ;;
87   uninstall)
88     _pip_installed