1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2026-01-01 20:11:06 +01:00

manual/7448

This commit is contained in:
Tanaka Akira 1999-08-19 11:18:05 +00:00
parent 04979daf4f
commit 9867c4091e
187 changed files with 1691 additions and 254 deletions

388
Completion/Base/_arguments Normal file
View file

@ -0,0 +1,388 @@
#autoload
# Complete the arguments of the current command according to the
# descriptions given as arguments to this function.
local long args rest ws cur nth def nm expl descr action opt arg tmp
# Associative arrays used to collect information about the options.
typeset -A opts mopts dopts dmopts odopts odmopts
# See if we support long options, too.
nth=$argv[(I)--]
if (( nth )); then
long=( "${(@)argv[nth+1,-1]}" )
argv=("${(@)argv[1,nth-1]}")
else
long=()
fi
# Now parse the arguments...
args=()
nth=1
while (( $# )); do
# This describes a one-shot option.
if [[ "$1" = [-+]* ]]; then
if [[ "$1" = *:* ]]; then
# If the option name ends in a `-', the first argument comes
# directly after the option, if it ends in a `+', the first
# argument *may* come directly after the option, otherwise it
# is in the next word.
if [[ "$1" = [^:]##-:* ]]; then
dopts[${${1%%:*}[1,-2]}]="${1#*:}"
elif [[ "$1" = [^:]##+:* ]]; then
odopts[${${1%%:*}[1,-2]}]="${1#*:}"
else
opts[${1%%:*}]="${1#*:}"
fi
else
opts[$1]=''
fi
elif [[ "$1" = \*[-+]* ]]; then
# The same for options that may appear more than once.
if [[ "$1" = *:* ]]; then
if [[ "$1" = [^:]##-:* ]]; then
dmopts[${${1[2,-1]%%:*}[1,-2]}]="${1#*:}"
elif [[ "$1" = [^:]##+:* ]]; then
odmopts[${${1[2,-1]%%:*}[1,-2]}]="${1#*:}"
else
mopts[${1[2,-1]%%:*}]="${1#*:}"
fi
else
mopts[${1[2,-1]}]=''
fi
elif [[ "$1" = \*:* ]]; then
# This is `*:...', describing `all other arguments'.
rest="${1[3,-1]}"
elif [[ "$1" = :* ]]; then
# This is `:...', describing `the next argument'.
args[nth++]="${1#*:}"
else
# And this is `n:...', describing the `n'th argument.
args[${1%%:*}]="${1#*:}"
nth=$(( ${1%%:*} + 1 ))
fi
shift
done
if [[ $#long -ne 0 && "$PREFIX" = --* ]]; then
# If the current words starts with `--' and we should use long
# options, just call...
_long_options "$long[@]"
else
# Otherwise parse the command line...
ws=( "${(@)words[2,-1]}" )
cur=$(( CURRENT-2 ))
nth=1
# ...until the current word is reached.
while [[ cur -gt 0 ]]; do
# `def' holds the description for the option we are currently after.
# Check if the next argument for the option is optional.
if [[ "$def" = :* ]]; then
opt=yes
else
opt=''
fi
arg=''
# Remove one description/action pair from `def' if that isn't empty.
if [[ -n "$def" ]]; then
if [[ "$def" = ?*:*:* ]]; then
def="${def#?*:*:}"
else
def=''
fi
else
# If it is empty, and the word starts with `--' and we should
# complete long options, just ignore this word, otherwise make sure
# we test for options below and handle normal arguments.
if [[ $#long -eq 0 || "$ws[1]" != --* ]]; then
opt=yes
arg=yes
else
def=''
fi
fi
if [[ -n "$opt" ]]; then
# `opt' was set above if we have to test if the word is an option.
# We first test for the simple options -- those without arguments or
# those whose arguments have to be given as separate words.
if (( $+opts[$ws[1]] )); then
# Options that may only be given once are removed from the
# associative array so that we are not offered them again.
def="$opts[$ws[1]]"
unset "opts[$ws[1]]"
elif (( $+mopts[$ws[1]] )); then
def="$mopts[$ws[1]]"
else
# If the word is none of the simple options, test for those
# whose first argument has to or may come directly after the
# option. This is done in four loops looking very much alike.
if (( $#dopts )); then
# First we get the option names.
tmp=( "${(@k)dopts}" )
# Then we loop over them and see if the current word begins
# with one of the option names.
while (( $#tmp )); do
[[ "$ws[1]" = ${tmp[1]}* ]] && break
shift 1 tmp
done
if (( $#tmp )); then
# It does. So use the description for it, but only from
# the second argument on, because we are searching the
# description for the next command line argument.
opt=''
def="$dopts[$tmp[1]]"
unset "dopts[$tmp[1]]"
if [[ "$def" = ?*:*:* ]]; then
def="${def#?*:*:}"
else
def=''
fi
fi
fi
if [[ -n "$opt" && $#dmopts -ne 0 ]]; then
tmp=( "${(@k)dmopts}" )
while (( $#tmp )); do
[[ "$ws[1]" = ${tmp[1]}* ]] && break
shift 1 tmp
done
if (( $#tmp )); then
opt=''
def="$dmopts[$tmp[1]]"
if [[ "$def" = ?*:*:* ]]; then
def="${def#?*:*:}"
else
def=''
fi
fi
fi
if [[ -n "$opt" && $#odopts -ne 0 ]]; then
tmp=( "${(@k)odopts}" )
while (( $#tmp )); do
[[ "$ws[1]" = ${tmp[1]}* ]] && break
shift 1 tmp
done
if (( $#tmp )); then
opt=''
def="$odopts[$tmp[1]]"
unset "odopts[$tmp[1]]"
# For options whose first argument *may* come after the
# option, we skip over the first description only if there
# is something after the option name on the line.
if [[ "$ws[1]" != "$tmp[1]" ]]; then
if [[ "$def" = ?*:*:* ]]; then
def="${def#?*:*:}"
else
def=''
fi
fi
fi
fi
if [[ -n "$opt" && $#odmopts -ne 0 ]]; then
tmp=( "${(@k)odmopts}" )
while (( $#tmp )); do
[[ "$ws[1]" = ${tmp[1]}* ]] && break
shift 1 tmp
done
if (( $#tmp )); then
opt=''
def="$odmopts[$tmp[1]]"
if [[ "$ws[1]" != "$tmp[1]" ]]; then
if [[ "$def" = ?*:*:* ]]; then
def="${def#?*:*:}"
else
def=''
fi
fi
fi
fi
# If we didn't find a matching option description and we were
# told to use normal argument descriptions, just increase
# our counter `nth'.
if [[ -n "$opt" && -n "$arg" ]]; then
def=''
(( nth++ ))
fi
fi
fi
shift 1 ws
(( cur-- ))
done
# Now generate the matches.
nm="$compstate[nmatches]"
if [[ -z "$def" || "$def" = :* ]]; then
# We either don't have a description for an argument of an option
# or we have a description for a optional argument.
if [[ -z "$def" ]]; then
# If we have none at all, use the one for this argument position.
def="$args[nth]"
[[ -z "$def" ]] && def="$rest"
fi
# In any case, we have to complete option names here, but we may
# be in a string that starts with an option names and continues with
# the first argument, test that (again, four loops).
opt=yes
if (( $#dopts )); then
# Get the option names.
tmp=( "${(@k)dopts}" )
while (( $#tmp )); do
if compset -P "$tmp[1]"; then
# The current string starts with the option name, so ignore
# that and complete the rest of the string.
def="$dopts[$tmp[1]]"
opt=''
break
fi
shift 1 tmp
done
fi
if [[ -n "$opt" && $#dmopts -ne 0 ]]; then
tmp=( "${(@k)dmopts}" )
while (( $#tmp )); do
if compset -P "$tmp[1]"; then
def="$dmopts[$tmp[1]]"
opt=''
break
fi
shift 1 tmp
done
fi
if [[ -n "$opt" && $#odopts -ne 0 ]]; then
tmp=( "${(@k)odopts}" )
while (( $#tmp )); do
if compset -P "$tmp[1]"; then
def="$odopts[$tmp[1]]"
opt=''
break
fi
shift 1 tmp
done
fi
if [[ -n "$opt" && $#odmopts -ne 0 ]]; then
tmp=( "${(@k)odmopts}" )
while (( $#tmp )); do
if compset -P "$tmp[1]"; then
def="$odmopts[$tmp[1]]"
opt=''
break
fi
shift 1 tmp
done
fi
if [[ -n "$opt" ]]; then
# We aren't in an argument directly after a option name, so
# all option names are possible matches.
_description expl option
compadd "$expl[@]" - "${(@k)opts}" "${(@k)mopts}" \
"${(@k)dopts}" "${(@k)dmopts}" \
"${(@k)odopts}" "${(@k)odmopts}"
fi
fi
# Now add the matches from the description, if any.
if [[ -n "$def" ]]; then
# Ignore the leading colon describing optional arguments.
[[ "$def" = :* ]] && def="$def[2,-1]"
# Get the description and the action.
descr="${def%%:*}"
action="${${def#*:}%%:*}"
_description expl "$descr"
if [[ -z "$action" ]]; then
# An empty action means that we should just display a message.
_message "$descr"
return 1
elif [[ "$action[1]" = \( ]]; then
# Anything inside `(...)' is added directly.
compadd "$expl[@]" - ${=action[2,-2]}
elif [[ "$action" = \ * ]]; then
# If the action starts with a space, we just call it.
$=action
else
# Otherwise we call it with the description-arguments built above.
action=( $=action )
"$action[1]" "$expl[@]" "${(@)action[2,-1]}"
fi
fi
# Set the return value.
[[ nm -ne "$compstate[nmatches]" ]]
fi

View file

@ -7,7 +7,8 @@ local lp ls n q suf=''
if [[ "$SUFFIX" = *\}* ]]; then
ISUFFIX="${SUFFIX#*\}}$ISUFFIX"
SUFFIX="${SUFFIX%%\}*}"
elif [[ "$LBUFFER" = *\$\{[^}]#\$\{[^}]#$PREFIX ]]; then
elif [[ "$LBUFFER" = *\$\{[^}]#\$\{[^}]#$PREFIX ||
"$compstate[insert]" = *menu* ]]; then
suf='}'
else
suf='} '

View file

@ -1,18 +1,21 @@
#compdef -command-
local nm=$compstate[nmatches] ret=1
local nm=$compstate[nmatches] ret=1 expl
# Complete jobs in implicit fg and bg
if [[ "$PREFIX[1]" = "%" ]]; then
compgen -j -P '%'
_description expl job
compgen "$expl[@]" -j -P '%'
[[ nm -ne compstate[nmatches] ]] && return
fi
compgen -c && ret=0
_description expl command
compgen "$expl[@]" -c && ret=0
if [[ nm -eq compstate[nmatches] ]]; then
_path_files -/g "*(*)"
_description expl 'executable file or directory'
_path_files "$expl[@]" -/g "*(*)"
else
return ret
fi

View file

@ -7,10 +7,11 @@ if [[ "$prev" = -o ]]; then
elif [[ "$prev" = -([no]t|ef) ]]; then
_files
else
local ret=1
local ret=1 expl
_files && ret=0
compgen -v && ret=0
_description expl parameter
compgen "$expl[@]" -v && ret=0
return ret
fi

View file

@ -1,3 +1,8 @@
#compdef -equal-
compgen -am
local expl
_description expl alias
compgen "$expl[@]" -a
_description expl command
compgen "$expl[@]" -m

View file

@ -9,9 +9,11 @@
# For options that get an argument after a `=', the function also tries
# to automatically find out what should be completed as the argument.
# The possible completions for option-arguments can be described with
# the arguments to this function. This is done by giving pairs of
# patterns and actions as consecutive arguments. The actions specify
# what should be done to complete arguments of those options that match
# the arguments to this function. Each argument contains one description
# of the form <pattern>:<message>:<action>. The message will be printed
# above the possible completion if the `description_format' configuration
# key is set (see the `_main_complete' file). The actions specify what
# should be done to complete arguments of those options that match
# the pattern. The action may be a list of words in brackets or in
# parentheses, separated by spaces. A list in brackets denotes
# possible values for an optional argument, a list in parentheses
@ -20,9 +22,9 @@
# command (probably with arguments) that should be invoked to complete
# after the equal sign. E.g.:
#
# _long_options '*\*' '(yes no)' \
# '*=FILE*' '_files' \
# '*=DIR*' '_files -/'
# _long_options '*\*:toggle:(yes no)' \
# '*=FILE*:file:_files' \
# '*=DIR*:directory:_files -/'
#
# This makes `yes' and `no' be completed as the argument of options
# whose description ends in a star, file names for options that
@ -46,23 +48,18 @@
# E.g. configure often lists only --enable but accepts both
# --enable and --disable options.
# _long_options -s '(#--enable- --disable)' will accept both forms.
#
# This function also accepts the `-X', `-J', and `-V' options which
# are given to `compadd'.
local opt expl group test i name action ret=1 tmp suffix iopts sopts
local opt test i name action descr expl ret=1 tmp suffix iopts sopts
setopt extendedglob
# Get the options.
group=()
expl=()
if [[ $1 = -*~--* ]]; then
while getopts "J:V:X:ti:s:" opt; do
while getopts "ti:s:" opt; do
case "$opt" in
[JV]) group=("-$opt" "$OPTARG");;
X) expl=(-X "$OPTARG");;
t) test=yes;;
i) if [[ "$OPTARG[1]" = '(' ]]; then
iopts=( ${=OPTARG[2,-2]} )
@ -99,7 +96,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
# No, store the new command name and clear the old parameters.
_lo_cache_cmd="$tmp"
(( $+_lo_cache_actions )) && unset "$_lo_cache_names[@]" _lo_cache_actions _lo_cache_names
(( $+_lo_cache_actions )) && unset "$_lo_cache_names[@]" _lo_cache_actions _lo_cache_names _lo_cache_descr
local opts pattern anum=1 tmpo str
typeset -U opts
@ -136,16 +133,17 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
# use the positional parameters we were given and a few standard
# ones. Then we loop through this table.
set -- "$@" '*=FILE*' '_files' '*=(DIR|PATH)*' '_files -/' '*' ''
set -- "$@" '*=FILE*:file:_files' '*=(DIR|PATH)*:directory:_files -/' '*:unknown:'
while [[ $# -gt 1 ]]; do
# First, we get the pattern and the action to use and take them
# from the positional parameters.
pattern="$1"
action="$2"
shift 2
pattern="${1%%:*}"
descr="${${1#*:}%%:*}"
action="${1#*:*:}"
shift
# We get all options matching the pattern and take them from the
# list we have built. If no option matches the pattern, we
@ -188,6 +186,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
_lo_cache_names[anum]="_lo_cache_optarg_$anum"
_lo_cache_actions[anum]="$action"
_lo_cache_descr[anum]="$descr"
eval "_lo_cache_optarg_${anum}=(\"\$tmpo[@]\")"
(( anum++ ))
fi
@ -201,6 +200,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
_lo_cache_names[anum]="_lo_cache_arg_$anum"
_lo_cache_actions[anum]="$action"
_lo_cache_descr[anum]="$descr"
eval "_lo_cache_arg_${anum}=(\"\$tmpo[@]\")"
(( anum++ ))
fi
@ -216,6 +216,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
if (( $#tmp )); then
_lo_cache_names[anum]="$name"
_lo_cache_actions[anum]="$action"
_lo_cache_descr[anum]="$descr"
eval "${name}=(\"\$tmp[@]\")"
(( anum++ ))
fi
@ -232,7 +233,7 @@ if [[ "$str" = *\=* ]]; then
# It contains a `=', now we ignore anything up to it, but first save
# the old contents of the special parameters we change.
local oipre opre osuf pre parto parta pat patflags anum=1
local oipre opre osuf pre parto parta partd pat patflags anum=1
oipre="$IPREFIX"
opre="$PREFIX"
@ -247,14 +248,23 @@ if [[ "$str" = *\=* ]]; then
for name in "$_lo_cache_names[@]"; do
action="$_lo_cache_actions[anum]"
descr="$_lo_cache_descr[anum]"
if (( ${(@)${(@P)name}[(I)$pre]} )); then
IPREFIX="${oipre}${pre}="
PREFIX="${str#*\=}"
SUFFIX=""
_description expl "$descr"
if [[ "$action[1]" = (\[|\() ]]; then
compadd - ${=action[2,-2]}
compadd "$expl[@]" - ${=action[2,-2]}
elif (( $#action )); then
$=action
if [[ "$action" = \ * ]]; then
$=action
else
action=($=action)
$action[1] "$expl[@]" $action[2,-1]
fi
fi
# We found the option string, return.
@ -276,6 +286,7 @@ if [[ "$str" = *\=* ]]; then
if [[ -z "$parto" ]]; then
parto="$tmp[1]"
parta="$action"
partd="$descr"
else
parto=-
fi
@ -292,11 +303,17 @@ if [[ "$str" = *\=* ]]; then
IPREFIX="${oipre}${parto}="
PREFIX="${str#*\=}"
SUFFIX=""
_description expl "$partd"
if (( $#parta )); then
if [[ "$parta[1]" = (\[|\() ]]; then
compadd - ${=parta[2,-2]}
else
compadd "$expl[@]" - ${=parta[2,-2]}
elif [[ "$parta" = \ * ]]; then
$=parta
else
action=($=parta)
$action[1] "$expl[@]" $action[2,-1]
fi
else
compadd -S '' - "$PREFIX"
@ -329,15 +346,17 @@ anum=1
for name in "$_lo_cache_names[@]"; do
action="$_lo_cache_actions[anum]"
_description expl option
if [[ "$name" = *_optarg_* ]]; then
compadd -M 'r:|-=* r:|=*' -Qq "$suffix[@]" -s "$str" - \
"${(@P)name}" && ret=0
compadd "$expl[@]" -M 'r:|-=* r:|=*' \
-Qq "$suffix[@]" -s "$str" - "${(@P)name}" && ret=0
elif [[ "$name" = *_arg_* ]]; then
compadd -M 'r:|-=* r:|=*' -Q "$suffix[@]" -s "$str" - \
"${(@P)name}" && ret=0
compadd "$expl[@]" -M 'r:|-=* r:|=*' \
-Q "$suffix[@]" -s "$str" - "${(@P)name}" && ret=0
elif [[ -z "$str" ]]; then
compadd -M 'r:|-=* r:|=*' -Q - \
"${(@P)name}" && ret=0
compadd "$expl[@]" -M 'r:|-=* r:|=*' - \
-Q "${(@P)name}" && ret=0
fi
(( anum++ ))
done

View file

@ -1,5 +1,7 @@
#compdef -math-
local expl
if [[ "$PREFIX" = *[^a-zA-Z0-9_]* ]]; then
IPREFIX="$IPREFIX${PREFIX%%[a-zA-Z0-9_]#}"
PREFIX="${PREFIX##*[^a-zA-Z0-9_]}"
@ -9,10 +11,5 @@ if [[ "$SUFFIX" = *[^a-zA-Z0-9_]* ]]; then
SUFFIX="${SUFFIX%%[^a-zA-Z0-9_]*}"
fi
compgen -v
#compdef -math-
IPREFIX="$IPREFIX${PREFIX%[a-zA-Z0-9_]*}"
PREFIX="${PREFIX##*[^a-zA-Z0-9_]}"
compgen -v
_description expl parameter
compgen "$expl[@]" -v

View file

@ -1,3 +1,7 @@
#compdef -parameter-
_parameters -S ' ' -r '['
if [[ "$compstate[insert]" = *menu* ]]; then
_parameters
else
_parameters -S ' ' -r '['
fi

View file

@ -1,17 +1,22 @@
#compdef -subscript-
local expl
if [[ "$PREFIX" = :* ]]; then
_description expl 'character class'
compadd -p: -S ':]' alnum alpha blank cntrl digit graph lower print punct \
space upper xdigit
elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
_description expl 'association key'
if [[ "$RBUFFER" = \]* ]]; then
compadd -S '' - "${(@kP)${compstate[parameter]}}"
compadd "$expl[@]" -S '' - "${(@kP)${compstate[parameter]}}"
else
compadd -S ']' - "${(@kP)${compstate[parameter]}}"
compadd "$expl[@]" -S ']' - "${(@kP)${compstate[parameter]}}"
fi
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
local list i j
_description expl 'array index'
ind=( {1..${#${(P)${compstate[parameter]}}}} )
list=()
for i in "$ind[@]"; do
@ -21,9 +26,9 @@ elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
done
if [[ "$RBUFFER" = \]* ]]; then
compadd -S '' -V default -y list - "$ind[@]"
compadd "$expl[@]" -S '' -V default -y list - "$ind[@]"
else
compadd -S ']' -V default -y list - "$ind[@]"
compadd "$expl[@]" -S ']' -V default -y list - "$ind[@]"
fi
else
_compalso -math-

View file

@ -7,7 +7,7 @@
# `(( compstate[nmatches] )) || compgen -nu -qS/'
# below that.
local c s dirs list
local d c s dirs list
if [[ "$SUFFIX" = */* ]]; then
ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
@ -24,6 +24,8 @@ if compset -P +; then
printf("%s\t%s\n", $1, $2); }' <<<$dirs)"
list=("${(@)list% *}")
c=(-y '$dirs' -k "($list)")
_description d 'directory stack'
elif compset -P -; then
dirs="$(dirs -v)"
list=("${(f)dirs}")
@ -31,8 +33,16 @@ elif compset -P -; then
printf("%s\t%s\n", $1, $2); }' <<<$dirs)"
list=("${(@)list% *}")
c=(-y '$dirs' -k "($list)")
_description d 'directory stack'
else
c=(-nu)
if (( $# )); then
d=( "$@" )
else
_description d user
fi
fi
compgen "$c[@]" "$s[@]"
compgen "$d[@]" "$c[@]" "$s[@]"

View file

@ -4,17 +4,22 @@
# `vared compconfig[<TAB>'. However, in this version the [ must be
# added by hand.
local expl
if [[ $PREFIX = *\[* ]]; then
local var=${PREFIX%%\[*}
local elt="${PREFIX#*\]}${SUFFIX%\]}"
local addclose
compset -p $(( ${#var} + 1 ))
if ! compset -S \]; then
addclose=(-S ']')
fi
if [[ ${(tP)var} = assoc* ]]; then
compadd $addclose - ${(kP)var}
_description expl 'association key'
compadd "$expl[@]" $addclose - ${(kP)var}
fi
else
compgen -v
_description expl parameter
compgen "$expl[@]" -v
fi

View file

@ -1,3 +1,6 @@
#compdef alias unalias
compgen -a
local expl
_description expl alias
compgen "$expl[@]" -a

View file

@ -1,3 +1,6 @@
#compdef shift
compgen -A
local expl
_description expl array
compgen "$expl[@]" -A

View file

@ -1,3 +1,6 @@
#compdef autoload
compadd - ${^fpath}/*(N:t)
local expl
_description expl 'shell function'
compadd "$expl[@]" - ${^fpath}/*(N:t)

View file

@ -1,3 +1,6 @@
#compdef bg
compgen -z -P '%'
local expl
_description expl 'suspended job'
compgen "$expl[@]" -z -P '%'

View file

@ -7,8 +7,12 @@
#
# Where appropriate, will complete keymaps instead of widgets.
local expl
if [[ "$words[2]" = -*[DAN]* || "$words[CURRENT-1]" = -*M ]]; then
compadd - $(bindkey -l)
_description expl keymap
compadd "$expl[@]" - $(bindkey -l)
else
compgen -b -M 'r:|-=* r:|=*'
_description expl widget
compgen "$expl[@]" -b -M 'r:|-=* r:|=*'
fi

View file

@ -5,5 +5,8 @@ if (( $CURRENT > 2 )); then
(( CURRENT -- ))
_normal
else
compgen -eB
local expl
_description expl 'builtin command'
compgen "$expl[@]" -eB
fi

View file

@ -14,6 +14,8 @@
emulate -L zsh
setopt extendedglob nonomatch
local expl
if [[ CURRENT -eq 3 ]]; then
# cd old new: look for old in $PWD and see what can replace it
local rep
@ -21,7 +23,8 @@ if [[ CURRENT -eq 3 ]]; then
rep=(${~PWD/$words[2]/*}~$PWD(-/N))
# Now remove all the common parts of $PWD and the completions from this
rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}})
(( ! $#rep )) || compadd $rep
_description expl replacement
(( ! $#rep )) || compadd "$expl[@]" $rep
elif [[ $PREFIX = [-+]* ]]; then
# pushd: just complete the numbers, but show the full directory list with
# numbers.
@ -50,7 +53,8 @@ elif [[ $PREFIX = [-+]* ]]; then
lines="${(F)list}"
# get the array of numbers only
list=(${list%%[ ]*})
compgen -y '$lines' -Q -k list && ret=0
_description expl 'directory stack index'
compgen "$expl[@]" -y '$lines' -Q -k list && ret=0
[[ -z $compstate[list] ]] && compstate[list]=list && ret=0
[[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0

View file

@ -4,5 +4,8 @@ if [[ CURRENT -ge 3 ]]; then
compset -n 2
_normal
else
compgen -em
local expl
_description expl command
compgen "$expl[@]" -em
fi

View file

@ -1,10 +1,22 @@
#compdef disable
local prev="$words[CURRENT-1]" ret=1
local prev="$words[CURRENT-1]" ret=1 expl
[[ "$prev" = -*a* ]] && compgen -ea && ret=0
[[ "$prev" = -*f* ]] && compgen -eF && ret=0
[[ "$prev" = -*r* ]] && compgen -ew && ret=0
[[ "$prev" != -* ]] && compgen -eB && ret=0
if [[ "$prev" = -*a* ]]; then
_description expl alias
compgen "$expl[@]" -ea && ret=0
fi
if [[ "$prev" = -*f* ]]; then
_description expl 'shell function'
compgen "$expl[@]" -eF && ret=0
fi
if [[ "$prev" = -*r* ]]; then
_description expl 'reserved word'
compgen "$expl[@]" -ew && ret=0
fi
if [[ "$prev" != -* ]]; then
_description expl 'builtin command'
compgen "$expl[@]" -eB && ret=0
fi
return ret

View file

@ -1,3 +1,7 @@
#compdef echotc
compadd al dc dl do le up al bl cd ce cl cr dc dl do ho is le ma nd nl se so up
local expl
_description expl 'terminal capability'
compadd "$expl[@]" \
al dc dl do le up al bl cd ce cl cr dc dl do ho is le ma nd nl se so up

View file

@ -1,10 +1,22 @@
#compdef enable
local prev="$words[CURRENT-1]" ret=1
local prev="$words[CURRENT-1]" ret=1 expl
[[ "$prev" = -*a* ]] && compgen -da && ret=0
[[ "$prev" = -*f* ]] && compgen -dF && ret=0
[[ "$prev" = -*r* ]] && compgen -dw && ret=0
[[ "$prev" != -* ]] && compgen -dB && ret=0
if [[ "$prev" = -*a* ]]; then
_description expl alias
compgen "$expl[@]" -da && ret=0
fi
if [[ "$prev" = -*f* ]]; then
_description expl 'shell function'
compgen "$expl[@]" -dF && ret=0
fi
if [[ "$prev" = -*r* ]]; then
_description expl 'reserved word'
compgen "$expl[@]" -dw && ret=0
fi
if [[ "$prev" != -* ]]; then
_description expl 'builtin command'
compgen "$expl[@]" -dB && ret=0
fi
return ret

View file

@ -1,9 +1,10 @@
#compdef fc
local prev="$words[CURRENT-1]"
local prev="$words[CURRENT-1]" expl
if [[ "$prev" = -*e ]]; then
compgen -c
_description expl command
compgen "$expl[@]" -c
elif [[ "$prev" = -[ARWI]## ]]; then
_files
fi

View file

@ -1,3 +1,6 @@
#compdef functions unfunction
compgen -F
local expl
_description expl 'shell function'
compgen "$expl[@]" -F

View file

@ -1,13 +1,17 @@
#compdef hash
local expl
if [[ "$words[2]" = -*d* ]]; then
if compset -P 1 '*\='; then
_path_files -g '*(-/)'
else
compgen -n -q -S '='
_description expl 'named directory'
compgen "$expl[@]" -n -q -S '='
fi
elif compset -P 1 '*\='; then
_files -/g '*(*)'
else
compgen -m -q -S '='
_description expl command
compgen "$expl[@]" -m -q -S '='
fi

View file

@ -1,3 +1,6 @@
#compdef disown fg jobs
compgen -j -P '%'
local expl
_description expl job
compgen "$expl[@]" -j -P '%'

View file

@ -1,15 +1,18 @@
#compdef kill
local list
local list expl
if compset -P 1 -; then
compadd $signals[1,-3]
_description expl signal
compadd "$expl[@]" $signals[1,-3]
else
local ret=1
compgen -P '%' -j && ret=0
_description expl job
compgen "$expl[@]" -P '%' -j && ret=0
list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}")
compadd -y list - ${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} &&
_description expl 'process ID'
compadd "$expl[@]" -y list - ${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} &&
ret=0
return ret

View file

@ -1,3 +1,6 @@
#compdef limit unlimit
compadd ${${(f)"$(limit)"}%% *}
local expl
_description expl 'process limits'
compadd "$expl[@]" ${${(f)"$(limit)"}%% *}

View file

@ -1,3 +1,7 @@
#compdef sched
if [[ CURRENT -eq 2 ]]; then
_message 'time specification'
return 1
fi
compset -n 3 && _normal

View file

@ -1,9 +1,11 @@
#compdef set
local prev="$words[CURRENT-1]"
local prev="$words[CURRENT-1]" expl
if [[ "$prev" = [-+]o ]]; then
compgen -o
_description expl 'zsh option'
compgen "$expl[@]" -o
elif [[ "$prev" = -A ]]; then
compgen -A
_description expl array
compgen "$expl[@]" -A
fi

View file

@ -1,10 +1,14 @@
#compdef stat
local expl
if [[ "$words[CURRENT-1]" = -[AH] ]]; then
compgen -A
_description expl array
compgen "$expl[@]" -A
else
_description expl 'inode element'
[[ "$PREFIX[1]" = + ]] &&
compadd - +device +inode +mode +nlink +uid +gid +rdev +size \
+atime +mtime +ctime +blksize +block +link
compadd "$expl[@]" - +device +inode +mode +nlink +uid +gid +rdev +size \
+atime +mtime +ctime +blksize +block +link
_files
fi

View file

@ -1,7 +1,11 @@
#compdef trap
local expl
if [[ CURRENT -eq 2 ]]; then
compgen -c
_description expl command
compgen "$expl[@]" -c
else
compgen -k signals
_description expl signal
compgen "$expl[@]" -k signals
fi

View file

@ -1,10 +1,22 @@
#compdef unhash
local fl="$words[2]" ret=1
local fl="$words[2]" ret=1 expl
[[ "$fl" = -*d* ]] && compgen -n && ret=0
[[ "$fl" = -*a* ]] && compgen -a && ret=0
[[ "$fl" = -*f* ]] && compgen -F && ret=0
[[ "$fl" != -* ]] && compgen -m && ret=0
if [[ "$fl" = -*d* ]]; then
_description expl 'named directory'
compgen "$expl[@]" -n && ret=0
fi
if [[ "$fl" = -*a* ]]; then
_description expl alias
compgen "$expl[@]" -a && ret=0
fi
if [[ "$fl" = -*f* ]]; then
_description expl 'shell function'
compgen "$expl[@]" -F && ret=0
fi
if [[ "$fl" != -* ]]; then
_description expl command
compgen "$expl[@]" -m && ret=0
fi
return ret

View file

@ -1,3 +1,6 @@
#compdef declare export integer local readonly typeset
compgen -v -q -S '='
local expl
_description expl parameter
compgen "$expl[@]" -v -q -S '='

View file

@ -11,10 +11,12 @@
# options for the ps command that are to be used when creating
# the list to display during completion.
local list ret=1
local list ret=1 expl
compgen -P '%' -j && ret=0
_description expl job
compgen "$expl[@]" -P '%' -j && ret=0
list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}")
compadd -y list - ${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0
_description expl 'process ID'
compadd "$expl[@]" -y list - ${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0
return ret

View file

@ -1,3 +1,10 @@
#compdef which whence where type
compgen -caF
local expl
_description expl command
compgen "$expl[@]" -c
_description expl alias
compgen "$expl[@]" -a
_description expl 'shell function'
compgen "$expl[@]" -F

View file

@ -7,11 +7,12 @@ _compskip=all
# zfcd_match and zfget_match (used for old-style completion)
# need to be installed for remote file and directory completion to work.
local subcom
local subcom expl
if [[ $words[1] = zftp ]]; then
if [[ $CURRENT -eq 2 ]]; then
compadd open params user login type ascii binary mode put \
_description expl sub-command
compadd "$expl[@]" open params user login type ascii binary mode put \
putat get getat append appendat ls dir local remote mkdir rmdir
return
fi
@ -24,13 +25,15 @@ case $subcom in
*(cd|ls|dir))
# complete remote directories; we could be smarter about hiding prefixes
zfcd_match $PREFIX $SUFFIX
(( $#reply )) && compadd -S/ -q - $reply
_description expl 'remote directory'
(( $#reply )) && compadd "$expl[@]" -S/ -q - $reply
;;
*(get(|at)|gcp|delete|remote))
# complete remote files
zfget_match $PREFIX $SUFFIX
(( $#reply )) && compadd -F fignore - $reply
_description expl 'remote file'
(( $#reply )) && compadd "$expl[@]" -F fignore - $reply
;;
*(put(|at)|pcp))
@ -40,18 +43,20 @@ case $subcom in
*(open|anon|params))
# complete hosts: should do cleverer stuff with user names
compgen -k hosts
_description expl host
compgen "$expl[@]" -k hosts
;;
*(goto|mark))
# complete bookmarks. First decide if ncftp mode is go.
_description expl bookmark
if [[ $words[2] = -*n* ]]; then
if [[ -f ~/.ncftp/bookmarks ]]; then
compadd - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks)
compadd "$expl[@]" - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks)
fi
else
if [[ -f ${ZFTP_BMFILE:=${ZDOTDIR:-$HOME}/.zfbkmarks} ]]; then
compadd - $(awk '{print $1}' $ZFTP_BMFILE)
compadd "$expl[@]" - $(awk '{print $1}' $ZFTP_BMFILE)
fi
fi
;;

View file

@ -1,7 +1,11 @@
#compdef zle
local expl
if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then
compgen -F
_description expl 'widget shell function'
compgen "$expl[@]" -F
else
compgen -b
_description expl widget
compgen "$expl[@]" -b
fi

View file

@ -1,11 +1,14 @@
#compdef zmodload
local fl="$words[2]"
local fl="$words[2]" expl
if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then
compgen -B
_description expl 'builtin command'
compgen "$expl[@]" -B
elif [[ "$fl" = -*u* ]]; then
_description expl module
compadd - $(zmodload)
else
_description expl 'module file'
compadd - ${^module_path}/*(N:t:r)
fi

View file

@ -1,2 +1,6 @@
#compdef -kn complete-word \e/
compgen -Q -H 0 ''
local expl
_description expl 'history word'
compgen "$expl[@]" -Q -H 0 ''

View file

@ -0,0 +1,22 @@
#autoload
local gropt=-J
if [[ "$1" = -V ]]; then
gropt=-V
shift
fi
if [[ -n "$compconfig[group_matches]" ]]; then
if [[ -n "$compconfig[description_format]" ]]; then
eval "$1=($gropt ${(q)2} -X ${(q)compconfig[description_format]//\\%d/$2})"
else
eval "$1=($gropt ${(q)2})"
fi
else
if [[ -n "$compconfig[description_format]" ]]; then
eval "$1=(-X ${(q)compconfig[description_format]//\\%d/$2})"
else
eval "$1=()"
fi
fi

View file

@ -22,6 +22,24 @@
# last_prompt
# If this is set to `always' the cursor is moved up to the last prompt
# after printing a list even if a numeric argument was given.
#
#
# Also, most completion functions use the configuration keys:
#
# description_format
# If this is set to a non-empty string, it will be displayed above
# all matches generated. The sequence `%d' in this string is replaced
# by a short description of what is completed in the current position
# of the command line.
#
# message_format
# Like `description_format', but used in places where no completions
# can automatically be generated but the completion system still wants
# to give a hint what is expected in that position.
#
# group_matches
# If this is set to a non-empty string, different types of matches will
# be put in different groups.
# If you want to complete only set or unset options for the unsetopt

19
Completion/Core/_message Normal file
View file

@ -0,0 +1,19 @@
#autoload
local format
format="$compconfig[message_format]"
[[ -z "$format" ]] && "$compconfig[description_format]"
if [[ -n "$format" ]]; then
if [[ $compstate[nmatches] -eq 0 ]]; then
compstate[list]=list
compstate[insert]=''
compadd -UX "${format//\\%d/$1}" -n ''
else
compadd -X "${format//\\%d/$1}" -n ''
fi
compstate[force_list]=yes
else
compadd -n ''
fi

View file

@ -29,13 +29,15 @@ fi
# See if there are any matching pattern completions.
if [[ "$_compskip" != *patterns* ]]; then
if [[ "$_compskip" != (all|*patterns*) ]]; then
for i in "$_patcomps[@]"; do
pat="${i% *}"
val="${i#* }"
if [[ "$cmd1" == $~pat || "$cmd2" == $~pat ]]; then
"$val" && ret=0
if [[ "$_compskip" = *patterns* || "$_compskip" = all ]]; then
if [[ "$_compskip" = *patterns* ]]; then
break
elif [[ "$_compskip" = all ]]; then
unset _compskip
return ret
fi
@ -55,15 +57,36 @@ fi
# And generate the matches, probably using default completion.
if [[ -z "$comp" ]]; then
if [[ "$_compskip" = *default* ]]; then
unset _compskip
return 1
if [[ -n "$comp" ]]; then
_compskip=patterns
"$comp" && ret=0
[[ "$_compskip" = (all|*patterns*) ]] && return ret
else
if [[ "$_compskip" != *default* ]]; then
name=-default-
comp="$_comps[-default-]"
fi
name=-default-
comp="$_comps[-default-]"
fi
[[ -z "$comp" ]] || "$comp" && ret=0
if [[ "$_compskip" != (all|*patterns*) ]]; then
for i in "$_postpatcomps[@]"; do
pat="${i% *}"
val="${i#* }"
if [[ "$cmd1" == $~pat || "$cmd2" == $~pat ]]; then
_compskip=default
"$val" && ret=0
if [[ "$_compskip" = *patterns* ]]; then
break
elif [[ "$_compskip" = all ]]; then
unset _compskip
return ret
fi
fi
done
fi
[[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] &&
"$comp" && ret=0
unset _compskip

View file

@ -2,4 +2,7 @@
# This should be used to complete all option names.
compgen "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -o
local expl
_description expl 'zsh option'
compgen "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -o

View file

@ -4,9 +4,13 @@
# extra options of compadd. It completes only non-local parameters. All
# arguments are given to compadd.
local expl
_description expl parameter
if zmodload -e parameter; then
setopt localoptions extendedglob
compadd "$@" - ${(k)parameters[(R)^*local*]}
compadd "$expl[@]" "$@" - ${(k)parameters[(R)^*local*]}
else
compadd "$@" - ${${${(f)"$(typeset +)"}:#*local *}##* }
compadd "$expl[@]" "$@" - ${${${(f)"$(typeset +)"}:#*local *}##* }
fi

View file

@ -91,6 +91,14 @@ while getopts "P:S:qr:R:W:F:J:V:X:f/g:" opt; do
esac
done
if (( ! ( $#group + $#expl ) )); then
if [[ "$sopt" = -/ ]]; then
_description expl directory
else
_description expl file
fi
fi
[[ -n "$tmp1" && $#addsfx -ne 0 ]] && addsfx[1]=-qS
# If we were given no file selection option, we behave as if we were given

View file

@ -4,4 +4,7 @@
# names of the options that were set when it was called in the array
# `_set_options'.
compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - $=_set_options
local expl
_description expl 'set zsh option'
compadd "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - $=_set_options

View file

@ -4,4 +4,7 @@
# names of the options that were set when it was called in the array
# `_set_options'.
compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - $=_unset_options
local expl
_description expl 'unset zsh option'
compadd "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - $=_unset_options

View file

@ -39,6 +39,12 @@ for _d_f in "$_patcomps[@]"; do
done >> $_d_file
print ")" >> $_d_file
print "\n_postpatcomps=(" >> $_d_file
for _d_f in "$_postpatcomps[@]"; do
print -r - "'${_d_f//\'/'\\''}'"
done >> $_d_file
print ")" >> $_d_file
print >> $_d_file
# Now dump the key bindings. We dump all bindings for zle widgets

View file

@ -68,10 +68,12 @@ while [[ $# -gt 0 && $1 = -[dDf] ]]; do
done
# The associative array containing the definitions for the commands.
# Definitions for patterns will be stored in the normal array `_patcomps'.
# Definitions for patterns will be stored in the normal arrays `_patcomps'
# and `_postpatcomps'.
typeset -gA _comps
_patcomps=()
_postpatcomps=()
# The associative array use to report information about the last
# cmpletion to the outside.
@ -106,6 +108,9 @@ fi
# function will be invoked when completing for a command whose name
# matches the pattern given as argument after the function name (in this
# case only one argument is accepted).
# The option `-P' is like `-p', but the function will be called after
# trying to find a function defined for the command on the line if no
# such function could be found.
# With the `-k' option a function for a special completion keys is
# defined and immediatly bound to those keys. Here, the extra arguments
# are the name of one of the builtin completion widgets and any number
@ -147,11 +152,11 @@ compdef() {
# Get the options.
while getopts "anpkd" opt; do
while getopts "anpPkd" opt; do
case "$opt" in
a) autol=yes;;
n) new=yes;;
[pk]) if [[ -n "$type" ]]; then
[pPk]) if [[ -n "$type" ]]; then
# Error if both `-p' and `-k' are given (or one of them
# twice).
echo "$0: type already set to $type"
@ -159,6 +164,8 @@ compdef() {
fi
if [[ "$opt" = p ]]; then
type=pattern
elif [[ "$opt" = P ]]; then
type=postpattern
else
type=key
fi
@ -187,6 +194,13 @@ compdef() {
_patcomps=("$_patcomps[@]" "$1 $func")
;;
postpattern)
if [[ $# -gt 1 ]]; then
echo "$0: only one pattern allowed"
return 1
fi
_postpatcomps=("$_postpatcomps[@]" "$1 $func")
;;
key)
if [[ $# -lt 2 ]]; then
echo "$0: missing keys"
@ -230,7 +244,12 @@ compdef() {
pattern)
# Note the space.
for i; do
_patcomps=("${(@)patcomps:#$i *}")
_patcomps=("${(@)_patcomps:#$i *}")
done
;;
postpattern)
for i; do
_postpatcomps=("${(@)_postpatcomps:#$i *}")
done
;;
key)
@ -359,7 +378,7 @@ if [[ -z "$_i_done" ]]; then
shift _i_line
case $_i_tag in
(\#compdef)
if [[ $_i_line[1] = -[pk](n|) ]]; then
if [[ $_i_line[1] = -[pPk](n|) ]]; then
compdef ${_i_line[1]}a "${_i_file:t}" "${(@)_i_line[2,-1]}"
else
compdef -na "${_i_file:t}" "${_i_line[@]}"

View file

@ -0,0 +1,3 @@
#compdef asciitopnm
_arguments '-d:divisor:' ':height:' ':width:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef fitstopgm
_arguments '-image:image number:' ':file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef fitstopnm
_arguments '-image:image number:' '-noraw' '-scanmax' '-printmax' \
'-min:minimum value:' '-max:maximum value:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef g3topbm
_arguments '-kludge' '-reversebits' '-stretch' ':file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef giftopnm
_arguments '-verbose' '-comments' '-image:image number:' \
':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef macptopbm
_arguments '-extraskip:number of bytes to skip:' ':file: _pbm_file'

View file

@ -0,0 +1,20 @@
#compdef -P (p[bgpn]m*|*top[bgpn]m)
local expl
if [[ "$words[1]" = pnm* ]]; then
pat='*.(#i)p[bgp]m'
elif [[ "$words[1]" = *top[bgpn]m ]]; then
pat="*.(#i)${words[1]%%top[bgpn]m}"
else
pat="*.(#i)${words[1][1,3]}"
fi
if (( $# )); then
expl=( "$@" )
else
_description expl 'picture file'
fi
_path_files "$expl[@]" -g "$pat" ||
_files "$expl[@]" -g '*.(#i)p[bgp]m'

View file

@ -0,0 +1,3 @@
#compdef pbmclean
_arguments '-connect' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pbmmake
_arguments '-white' '-black' '-gray' ':width:' ':height:'

View file

@ -0,0 +1,3 @@
#compdef pbmmask
_arguments '-expand' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pbmpscale
_arguments ':scale factor:' ':file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef pbmreduce
_arguments '-floyd' '-fs' '-threshold' '-value:threshold value:' \
':reduction factor:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pbmtext
_arguments '-font:font file:_files -g *.(#i)pbm' '*:text:'

View file

@ -0,0 +1,3 @@
#compdef pbmto10x
_arguments '-h' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pbmtobg pbmtobbnbg
_arguments ':raster operation:' ':x position:' ':y position:'

View file

@ -0,0 +1,3 @@
#compdef pbmtoepsi
_arguments '--bbonly' ':file: _pbmfile'

View file

@ -0,0 +1,3 @@
#compdef pbmtolj
_arguments '-resolution:resolution:(75 100 150 300)' ':file: _pbm_file'

View file

@ -0,0 +1,5 @@
#compdef pbmtoln03
_arguments '-l:left margin:' '-r:right margin:' \
'-t:top margin:' '-b:bottom margin:' \
'-f:form length:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pbmtolps
_arguments '-dpi:resolution:' ':file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef pbmtomacp
_arguments '-l:left offset:' '-r:right offset:' \
'-t:top offset:' '-b:bottom offset:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pbmtopgm
_arguments ':width:' ':height:' ':file: _pbm_file'

View file

@ -0,0 +1,11 @@
#compdef pbmtopk
# This could be improved...
_arguments '-s:design size:' '-C:coding scheme:' '-F:font family:' \
'-f:option file:_files' '-c:character number:' \
'-W:width:' '-H:height:' '-D:depth:' '-I:italic correction:' \
'-h:horizontal escapement:' '-v:vertical escapement:' \
'-x:x offset:' '-y:y offset:' \
':pk file:_files -g *.(#i)pk' ':tfm file:_files -g *.(#i)tfm' \
'*:file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef pbmupc
_arguments '-s1' '-s2' ':product type:' ':manufacturer code:' \
':product code:'

View file

@ -0,0 +1,5 @@
#compdef pgmcrater
_arguments '-number:number of craters:' '-gamma:factor:' \
'-height:height:' '-ysize:height:' \
'-width:width:' '-xsize:width:'

View file

@ -0,0 +1,3 @@
#compdef pgmkernel
_arguments '-weight:weight:' ':width:' ':height:'

View file

@ -0,0 +1,3 @@
#compdef pgmnoise
_arguments ':width:' ':height:'

View file

@ -0,0 +1,5 @@
#compdef pgmnorm ppmnorm
_arguments '-bpercent:black percentage:' '-bvalue:black pixel value:' \
'-wpercent:white percentage:' '-wvalue:white pixel value:' \
':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pgmoil
_arguments '-n:smear size:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pgmramp
_arguments '-lr' '-tb' '-rectangle' '-ellipse' ':width:' ':height:'

View file

@ -0,0 +1,3 @@
#compdef pgmtexture
_arguments '-d:distance:' ':file: _pbm_file'

View file

@ -0,0 +1,5 @@
#compdef pgmtopbm
_arguments '-floyd' '-fs' '-threshold' '-dither8' '-d8' '-cluster3' '-c3' \
'-cluster4' '-c4' '-cluster8' '-c8' '-value:threshold value:' \
':file: _pbm_file'

View file

@ -0,0 +1,21 @@
#compdef pgmtoppm
local ret=1 expl
if [[ CURRENT -eq 2 ]]; then
if compset -P '?*-'; then
_colors
return
fi
_colors && ret=0
_description expl option
compadd "$expl[@]" - -map && ret=0
return ret
elif [[ CURRENT -eq 3 && "$words[2]" = -map ]]; then
_description expl 'map file'
_files "$expl[@]" -g '*.(#i)ppm'
else
_pbm_file
fi

View file

@ -0,0 +1,4 @@
#compdef pktopbm
_arguments ':pk file:_file -g *.(#i)pk' '-c:character number:' \
'*:file: _pbm_file'

View file

@ -0,0 +1,6 @@
#compdef pnmalias
_arguments '-bgcolor:background color:_colors' \
'-fgcolor:foreground color:_colors' \
'-bonly' '-fonly' '-balias' '-falias' \
'-weight:central aliasing weight:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmarith
_arguments '-add' '-subtract' '-multiply' '*:file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef pnmcat
_arguments '-white' '-black' '-leftright' '-lr' '-topbottom' '-tb' \
'-jtop' '-jbottom' '-jleft' '-jright' '*:file: _pbm_file'

View file

@ -0,0 +1,5 @@
#compdef pnmcomp
_arguments '-invert' '-xoff:x offset:' '-yoff:y offset:' \
'-alpha:alpha mask file:_files -g *.(#i)pgm' \
':overlay file:_pbm_file' '*:file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmconvol
_arguments ':convolution file:_pbm_file' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmcrop
_arguments '-white' '-black' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmcut
_arguments ':x position:' ':y position:' ':width:' ':height:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmdepth
_arguments ':new maximum value:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmenlarge
_arguments ':enlargement factor:' ':file: _pbm_file'

View file

@ -0,0 +1,5 @@
#compdef pnmflip
_arguments '-leftright' '-lr' '-topbottom' '-tb' '-transpose' '-xy' \
'-rotate90' '-r90' '-ccw' '-rotate270' '-r270' '-cw' \
':file: _pbm_file'

View file

@ -0,0 +1,16 @@
#compdef pnmgamma
local ret=1
if [[ CURRENT -eq 2 ]]; then
_message 'gamma value or red gamma value'
elif [[ CURRENT -eq 3 ]]; then
_pbm_file && ret=0
_message 'green gamma value'
elif [[ CURRENT -eq 4 ]]; then
_message 'blue gamma value'
elif [[ CURRENT -eq 5 ]]; then
_pbm_file && ret=0
fi
return ret

View file

@ -0,0 +1,4 @@
#compdef pnmhistmap
_arguments '-black' '-white' '-max:maximum value:' '-verbose' \
':file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef pnmindex
_arguments '-size:image size:' '-across:images per row:' \
'-colors:number of colors:' '-black' '*:file: _pbm_file'

View file

@ -0,0 +1,4 @@
#compdef pnmmargin
_arguments '-white' '-black' '-color:color: _colors' \
':border width:' ':file: _pbm_file'

View file

@ -0,0 +1,3 @@
#compdef pnmnlfilt
_arguments ':alpha value:' ':radius:' ':file: _pbm_file'

View file

@ -0,0 +1,6 @@
#compdef pnmpad
_arguments '-black' '-white' \
'-l-:left border width:' '-r-:right border width:' \
'-t-:top border width:' '-b-:bottom border width:' \
':file: _pbm_file'

Some files were not shown because too many files have changed in this diff Show more