# ss(8) completion -*- shell-script -*- proc _ss { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return match $prev { with -h|--help|-V|--version return with -f|--family setglobal COMPREPLY = '( '$( compgen -W 'unix inet inet6 link netlink' \ -- "$cur" ) ) return with -A|--query var prefix = ''; [[ $cur == *,* ]] && set prefix = ""$(cur%,*),"" setglobal COMPREPLY = '( '$( compgen -P "$prefix" -W '$( "$1" --help | \ sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p" )' \ -- "${cur##*,}" ) ) return with -D|--diag|-F|--filter _filedir return } $split && return if [[ $cur == -* ]] { setglobal COMPREPLY = '( '$( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } } && complete -F _ss ss # ex: ts=4 sw=4 et filetype=sh