# iperf(1) completion -*- shell-script -*- proc _iperf { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return match $prev { with -h|--help|-v|--version|-i|--interval|-l|--len|-p|--port|-w|--window|\ -M|--mss|-b|--bandwidth|-n|--num|-t|--time|-L|--listenport|-P|\ --parallel|-T|--ttl|-Z|--linux-congestion return with -f|--format setglobal COMPREPLY = '( '$( compgen -W 'k m K M' -- "$cur" ) ) return with -o|--output|-F|--fileinput _filedir return with -B|--bind _available_interfaces -a _ip_addresses return with -c|--client _known_hosts_real $cur return with -x|--reportexclude setglobal COMPREPLY = '( '$( compgen -W 'C D M S V' -- "$cur" ) ) return with -y|--reportstyle setglobal COMPREPLY = '( '$( compgen -W 'C' -- "$cur" ) ) return } $split && return # Filter mode specific options var i = '', filter = 'cat' for i in [$(words[@])] { match $i { with -s|--server set filter = ''sed -e /^Client.specific/,/^$/d'' with -c|--client set filter = ''sed -e /^Server.specific/,/^$/d'' } } [[ $filter != cat ]] && set filter = '' -e /--client/d -e /--server/d'' setglobal COMPREPLY = '( '$( compgen -W \ '$( "$1" --help 2>&1 | $filter | _parse_help - )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _iperf iperf # ex: ts=4 sw=4 et filetype=sh