_pip 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4
  2. #autoload
  3. # pip zsh completion, based on homebrew completion
  4. _pip_all() {
  5. # we cache the list of packages (originally from the macports plugin)
  6. if (( ! $+piplist )); then
  7. zsh-pip-cache-packages
  8. piplist=($(cat $ZSH_PIP_CACHE_FILE))
  9. fi
  10. }
  11. _pip_installed() {
  12. installed_pkgs=(`pip freeze | cut -d '=' -f 1`)
  13. }
  14. local -a _1st_arguments
  15. _1st_arguments=(
  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. 'show:show information about installed packages'
  20. 'install:install packages'
  21. 'search:search PyPI'
  22. 'uninstall:uninstall packages'
  23. 'unzip:unzip individual packages'
  24. 'zip:zip individual packages'
  25. )
  26. local expl
  27. local -a all_pkgs installed_pkgs
  28. _arguments \
  29. '(--version)--version[show version number of program and exit]' \
  30. '(-h --help)'{-h,--help}'[show help]' \
  31. '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \
  32. '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
  33. '(-v --verbose)'{-v,--verbose}'[give more output]' \
  34. '(-q --quiet)'{-q,--quiet}'[give less output]' \
  35. '(--log)--log[log file location]' \
  36. '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
  37. '(--timeout)--timeout[socket timeout (default 15s)]' \
  38. '*:: :->subcmds' && return 0
  39. if (( CURRENT == 1 )); then
  40. _describe -t commands "pip subcommand" _1st_arguments
  41. return
  42. fi
  43. case "$words[1]" in
  44. search)
  45. _arguments \
  46. '(--index)--index[base URL of Python Package Index]' ;;
  47. freeze)
  48. _arguments \
  49. '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
  50. install)
  51. _arguments \
  52. '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
  53. '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
  54. '(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \
  55. '(--no-deps --no-dependencies)'{--no-deps,--no-dependencies}'[iIgnore package dependencies]' \
  56. '(--no-install)--no-install[only download packages]' \
  57. '(--no-download)--no-download[only install downloaded packages]' \
  58. '(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
  59. '(--single-version-externally-managed)--single-version-externally-managed[do not download/install dependencies. requires --record or --root]'\
  60. '(--root)--root[treat this path as a fake chroot, installing into it. implies --single-version-externally-managed]'\
  61. '(--record)--record[file to record all installed files to.]'\
  62. '(-r --requirement)'{-r,--requirement}'[requirements file]: :_files'\
  63. '(-e --editable)'{-e,--editable}'[path of or url to source to link to instead of installing.]: :_files -/'\
  64. '1: :->packages' && return 0
  65. if [[ "$state" == packages ]]; then
  66. _pip_all
  67. _wanted piplist expl 'packages' compadd -a piplist
  68. fi ;;
  69. uninstall)
  70. _pip_installed
  71. _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
  72. show)
  73. _pip_installed
  74. _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
  75. esac