# protoc completion -*- shell-script -*- proc _protoc { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return match $prev { with --proto_path|--cpp_out|--java_out|--python_out _filedir -d return with --version|-h|--help|--encode|--decode return with --descriptor_set_out _filedir return with --error_format setglobal COMPREPLY = '( '$( compgen -W 'gcc msvs' -- "$cur" ) ) return with --plugin if [[ $cur != *=* ]] { compopt -o filenames setglobal COMPREPLY = '( '$( compgen -c -- "$cur" ) ) } return } $split && return match $cur { with -o* set cur = $(cur:2) _filedir setglobal COMPREPLY = '( '"${COMPREPLY[@]/#/-o}" ) return with -I* set cur = $(cur:2) _filedir -d setglobal COMPREPLY = '( '"${COMPREPLY[@]/#/-I}" ) return with -* setglobal COMPREPLY = '( '$( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) var i = '' for i in [$(!COMPREPLY[@])] { [[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]' } [[ $COMPREPLY == *= ]] && compopt -o nospace return } _filedir proto } && complete -F _protoc protoc # ex: ts=4 sw=4 et filetype=sh