]> git.rmz.io Git - dotfiles.git/blob - zsh/plugins/pip/_pip
merge oh-my-zsh into subdir
[dotfiles.git] / zsh / plugins / pip / _pip
1 #compdef pip
2 #autoload
3
4 # pip zsh completion, based on homebrew completion
5
6 _pip_all() {
7 # we cache the list of packages (originally from the macports plugin)
8 if (( ! $+piplist )); then
9 echo -n " (caching package index...)"
10 piplist=($(pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'))
11 fi
12 }
13
14 _pip_installed() {
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 )
29
30 local expl
31 local -a all_pkgs installed_pkgs
32
33 _arguments \
34 '(--version)--version[show version number of program and exit]' \
35 '(-h --help)'{-h,--help}'[show help]' \
36 '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \
37 '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
38 '(-v --verbose)'{-v,--verbose}'[give more output]' \
39 '(-q --quiet)'{-q,--quiet}'[give less output]' \
40 '(--log)--log[log file location]' \
41 '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
42 '(--timeout)--timeout[socket timeout (default 15s)]' \
43 '*:: :->subcmds' && return 0
44
45 if (( CURRENT == 1 )); then
46 _describe -t commands "pip subcommand" _1st_arguments
47 return
48 fi
49
50 case "$words[1]" in
51 search)
52 _arguments \
53 '(--index)--index[base URL of Python Package Index]' ;;
54 freeze)
55 _arguments \
56 '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
57 install)
58 _arguments \
59 '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
60 '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
61 '(--no-deps --no-dependencies)'{--no-deps,--no-dependencies}'[iIgnore package dependencies]' \
62 '(--no-install)--no-install[only download packages]' \
63 '(--no-download)--no-download[only install downloaded packages]' \
64 '(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
65 '1: :->packages' && return 0
66
67 if [[ "$state" == packages ]]; then
68 _pip_all
69 _wanted piplist expl 'packages' compadd -a piplist
70 fi ;;
71 uninstall)
72 _pip_installed
73 _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
74 esac