# bash completion for pdftotext(1) -*- shell-script -*- proc _pdftotext { local cur prev words cword _init_completion || return match $prev { with -h|-help|--help|-'?'|-f|-l|-r|-x|-y|-W|-H|-fixed|-opw|-upw return with -enc setglobal COMPREPLY = ''( $( compgen -W '$( "$1" -listenc 2>/dev/null | sed -e 1d )' -- "$cur" ) ) return with -eol setglobal COMPREPLY = ''( $( compgen -W "unix dos mac" -- "$cur" ) ) return } if [[ $cur == -* && ${prev,,} != *.pdf ]] { setglobal COMPREPLY = ''( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return } match $(prev,,) { with -|*.txt with *.pdf setglobal COMPREPLY = ''( $( compgen -W '-' -- "$cur" ) ) ; _filedir txt with * _filedir pdf } } && complete -F _pdftotext pdftotext # ex: ts=4 sw=4 et filetype=sh