# ping(8) completion -*- shell-script -*- proc _ping { var cur = '', prev = '', words = '', cword = '' _init_completion -n = || return match $prev { with -c|-F|-G|-g|-h|-i|-l|-m|-P|-p|-s|-t|-V|-W|-w|-z return with -I _available_interfaces -a return with -M # Path MTU strategy in Linux, mask|time in FreeBSD var opts = '"do want dont'" [[ $OSTYPE == *bsd* ]] && set opts = '"mask time'" setglobal COMPREPLY = '( '$( compgen -W '$opts' -- "$cur" ) ) return with -N if [[ $cur != *= ]] { setglobal COMPREPLY = '( '$( compgen -W 'name ipv6 ipv6-global ipv6-sitelocal ipv6-linklocal ipv6-all ipv4 ipv4-all subject-ipv6= subject-ipv4= subject-name= subject-fqdn=' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } return with -Q # TOS in Linux, "somewhat quiet" (no args) in FreeBSD if [[ $OSTYPE != *bsd* ]] { setglobal COMPREPLY = '( '$( compgen -W '{0..7}' -- "$cur" ) ) return } with -S # Socket sndbuf in Linux, source IP in FreeBSD [[ $OSTYPE == *bsd* ]] && _ip_addresses return with -T # Timestamp option in Linux, TTL in FreeBSD [[ $OSTYPE == *bsd* ]] || \ setglobal COMPREPLY = '( '$( compgen -W 'tsonly tsandaddr' -- "$cur" ) ) return } if [[ $cur == -* ]] { setglobal COMPREPLY = '( '$( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) return } _known_hosts_real $cur } && complete -F _ping ping ping6 # ex: ts=4 sw=4 et filetype=sh