# patch(1) completion -*- shell-script -*- proc _patch { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return match $prev { with -p|--strip|-D|--ifdef|-B|--prefix|-Y|--basename-prefix|-z|--suffix|\ -g|--get return with -F|--fuzz setglobal COMPREPLY = '( '$( compgen -W '{0..3}' -- "$cur" ) ) return with -i|--input _filedir '@(?(d)patch|dif?(f))' return with -o|--output|-r|--reject-file [[ ! $cur || $cur == - ]] && setglobal COMPREPLY = '( '- ) _filedir return with --quoting-style setglobal COMPREPLY = '( '$( compgen -W 'literal shell shell-always c escape' \ -- "$cur" ) ) return with -V|--version-control setglobal COMPREPLY = '( '$( compgen -W 'simple numbered existing' -- "$cur" ) ) return with -d|--directory _filedir -d return with --reject-format setglobal COMPREPLY = '( '$( compgen -W 'context unified' -- "$cur" ) ) return with --read-only setglobal COMPREPLY = '( '$( compgen -W 'ignore warn fail' -- "$cur" ) ) return } $split && return if [[ $cur == -* ]] { setglobal COMPREPLY = '( '$( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return } var args = '' _count_args match $args { with 1 _filedir with 2 _filedir '@(?(d)patch|dif?(f))' } } && complete -F _patch patch # ex: ts=4 sw=4 et filetype=sh