_pip 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #compdef pip
  2. #autoload
  3. # pip zsh completion, based on homebrew completion
  4. _pip_installed() {
  5. installed_pkgs=(`pip freeze`)
  6. }
  7. local -a _1st_arguments
  8. _1st_arguments=(
  9. 'bundle:Create pybundles (archives containing multiple packages)'
  10. 'freeze:Output all currently installed packages (exact versions) to stdout'
  11. 'help:Show available commands'
  12. 'install:Install packages'
  13. 'search:Search PyPI'
  14. 'uninstall:Uninstall packages'
  15. 'unzip:Unzip individual packages'
  16. 'zip:Zip individual packages'
  17. )
  18. local expl
  19. local -a pkgs installed_pkgs
  20. _arguments \
  21. '(--version)--version[Show version number of program and exit]' \
  22. '(-v --verbose)'{-v,--verbose}'[Give more output]' \
  23. '(-q --quiet)'{-q,--quiet}'[Give less output]' \
  24. '(-h --help)'{-h,--help}'[Show help]' \
  25. '*:: :->subcmds' && return 0
  26. if (( CURRENT == 1 )); then
  27. _describe -t commands "pip subcommand" _1st_arguments
  28. return
  29. fi
  30. case "$words[1]" in
  31. list)
  32. if [[ "$state" == forms ]]; then
  33. _pip_installed
  34. _requested installed_pkgs expl 'installed packages' compadd -a installed_pkgs
  35. fi ;;
  36. uninstall)
  37. _pip_installed
  38. _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
  39. esac