# pydoc completion -*- shell-script -*- proc _pydoc { var cur = '', prev = '', words = '', cword = '' _init_completion || return match $prev { with -k|-p return with -w _filedir return } if [[ "$cur" == -* ]] { setglobal COMPREPLY = '( '$( compgen -W \ '$( "$1" | sed -e "s/^pydoc3\{0,1\} //" | _parse_help - )' \ -- "$cur" ) ) return } setglobal COMPREPLY = '( '$( compgen -W 'keywords topics modules' -- "$cur" ) ) var python = 'python'; [[ $1 == *3* ]] && set python = 'python3' _xfunc python _python_modules $python # Note that we don't do "pydoc modules" as it is known to hang on # some systems; _python_modules tends to work better and faster. setglobal COMPREPLY = '( '$( compgen -W \ '$( $1 keywords topics | sed -e /^Here/d )' -- "$cur" ) ) _filedir py } && complete -F _pydoc pydoc pydoc3 # ex: ts=4 sw=4 et filetype=sh