mirror of
https://github.com/zsh-users/zsh-completions.git
synced 2026-11-27 11:30:31 +08:00
Having a vim modeline or emacs local variable line somewhere in the middle of the file isn't really helpful. By default, vim will only check the first and last 5 lines of a file for a modeline (assuming the modeline option is enabled). Emacs is even more strict about the type of local variable line that was in use, it will only check the first line of the file or the second line if the first line specifies a script interpreter (which isn't the case here). Move the vim modeline to the end of the file so that it can actually be found by vim but is out of the way for editing. For emacs more work is required, convert that to the more verbose Local Variables syntax which emacs will look for starting 3000 characters from the end of the file. Also there is no zsh mode for emacs (according to zsh-users/zsh-completions#75), use the "Shell-Script" mode instead. This seems to automatically detect that the files are for zsh. I'm not an emacs user, so I haven't tested that portion much. But, this does at least improve the syntax highlighting there.
126 lines
3.6 KiB
Bash
126 lines
3.6 KiB
Bash
#compdef pip
|
|
# ------------------------------------------------------------------------------
|
|
# Description
|
|
# -----------
|
|
#
|
|
# Completion script for pip (http://pypi.python.org/pypi/pip).
|
|
#
|
|
# Source: https://github.com/technolize/zsh-completion-funcs
|
|
#
|
|
# ------------------------------------------------------------------------------
|
|
# Authors
|
|
# -------
|
|
#
|
|
# * technolize (https://github.com/technolize)
|
|
#
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
local ret=1 state
|
|
|
|
local -a common_ops
|
|
common_ops=(
|
|
"--version[display version number]"
|
|
{-h,--help}"[show help]"
|
|
{-E,--environment=}"[virtualenv environment to run pip]:environment:_directories"
|
|
{-s,--enable-site-packages}"[include site-packages in virtualenv]"
|
|
{-v,--verbose}"[give more output]"
|
|
{-q,--quiet}"[give less output]"
|
|
"--log=[log file where a complete record will be kept]"
|
|
"--proxy=[specify a proxy in the form user:passwd@proxy.server:port]:proxy"
|
|
"--timeout=[set the socket timeout (default 15 seconds)]:second"
|
|
)
|
|
|
|
_directories () {
|
|
_wanted directories expl directory _path_files -/ "$@" -
|
|
}
|
|
|
|
typeset -A opt_args
|
|
_arguments \
|
|
':subcommand:->subcommand' \
|
|
$common_ops \
|
|
'*::options:->options' && ret=0
|
|
|
|
case $state in
|
|
subcommand)
|
|
local -a subcommands
|
|
subcommands=(
|
|
"bundle:create pybundle"
|
|
"freeze:put all currently installed packages"
|
|
"help:show available commands"
|
|
"install:install packages"
|
|
"search:search pypi"
|
|
"uninstall:uninstall packages"
|
|
"unzip:unzip undividual packages"
|
|
"zip:zip dividual packages"
|
|
)
|
|
|
|
_describe -t subcommands 'pip subcommand' subcommands && ret=0
|
|
;;
|
|
|
|
options)
|
|
local -a args
|
|
args=(
|
|
$common_ops
|
|
)
|
|
|
|
local -a requirement
|
|
requirement=(
|
|
{-r,--requirement=}"[install all the packages listed in the given requirements file]:filename:_files"
|
|
)
|
|
|
|
local -a findlink
|
|
findlink=(
|
|
{-f,--find-links=}"[URL to look for packages at]:url"
|
|
)
|
|
|
|
case $words[1] in
|
|
bundle | install)
|
|
args+=(
|
|
{-e,--editable=}"[install a package directly from a checkout]:VCS+REPOS_URL[@REV]#egg=PACKAGE"
|
|
$requirement
|
|
$findlink
|
|
{-i,--index-url=,--pypi-url=}"[base URL of Python Package Index]:URL"
|
|
"--extra-index-url=[extra URLs of package indexes to use]:URL"
|
|
{-b,--build=,--build-dir=}"[unpack packages into DIR]:directory:_directories"
|
|
{--src=,--source=}"[check out --editable packages into DIR]:directory:_directories"
|
|
{-U,--upgrade}"[upgrade all packages to the newest available version]"
|
|
{-I,--ignore-installed}"[ignore the installed packages]"
|
|
"--noinstall[download and unpack all packages, but don't actually install them]"
|
|
"--install-option=[extra arguments to be supplied to the setup.py install command]"
|
|
)
|
|
;;
|
|
|
|
freeze)
|
|
args+=(
|
|
$requirement
|
|
$findlink
|
|
)
|
|
;;
|
|
|
|
unzip | zip)
|
|
args+=(
|
|
"--unzip[unzip a package]"
|
|
"--no-pyc[do not include .pyc files in zip files]"
|
|
{-l,--list}"[list the packages available, and their zip status]"
|
|
"--sort-files[with --list, sort packages according to how many files they contain]"
|
|
"--path=[restrict operation to the given paths]:paths"
|
|
{-n,--simulate}"[do not actually perform the zip/unzip operation]"
|
|
)
|
|
;;
|
|
esac
|
|
|
|
_arguments $args && ret=0
|
|
;;
|
|
esac
|
|
|
|
return ret
|
|
|
|
# Local Variables:
|
|
# mode: Shell-Script
|
|
# sh-indentation: 2
|
|
# indent-tabs-mode: nil
|
|
# sh-basic-offset: 2
|
|
# End:
|
|
# vim: ft=zsh sw=2 ts=2 et
|