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