# htop(1) completion -*- shell-script -*- proc _htop { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return match $prev { with -s|--sort-key setglobal COMPREPLY = '( '$( compgen -W '$( "$1" -s help )' -- "$cur" ) ) return with -u|--user setglobal COMPREPLY = '( '$( compgen -u -- "$cur" ) ) return with -d|--delay # argument required but no completions available return } $split && return if [[ "$cur" == -* ]] { setglobal COMPREPLY = '( '$( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return } } && complete -F _htop htop # ex: ts=4 sw=4 et filetype=sh