# tshark(1) completion -*- shell-script -*- proc _tshark { local cur prev words cword _init_completion -n : || return match $prev { with -f|-s|-B|-D|-L|-c|-R|-N|-d|-C|-e|-E|-z|-h|-v|-o|-K return with -i _available_interfaces -a return with -y local opts i for (( i=${#words[@]}-1; i > 0; i-- )); do if [[ ${words[i]} == -i ]]; then opts+="-i ${words[i+1]}" break fi done setglobal COMPREPLY = ''( $( compgen -W "$( "$1" $opts -L 2>&1 | \ awk '/^ / { print $1 }' )" -- "$cur" ) ) return with -a|-b setglobal COMPREPLY = ''( $( compgen -W 'duration: filesize: files:' \ -- "$cur" ) ) [[ $COMPREPLY == *: ]] && compopt -o nospace return with -r _filedir pcap return with -H _filedir return with -w _filedir [[ $cur == @(|-) ]] && setglobal COMPREPLY = ''( - ) return with -F setglobal COMPREPLY = ''( $( compgen -W "$( "$1" -F 2>&1 | \ awk '/^ / { print $1 }' )" -- "$cur" ) ) return with -O local prefix=; [[ $cur == *,* ]] && setglobal prefix = ""$(cur%,*),"" setglobal COMPREPLY = ''( $( compgen -P "$prefix" -W \ "$( "$1" -G protocols 2>&1 | cut -f 3 )" \ -- "${cur##*,}" ) ) return with -T # TODO: could be parsed from "-T ." output setglobal COMPREPLY = ''( $( compgen -W 'ps text pdml psml fields' -- "$cur" ) ) return with -t # TODO: could be parsed from "-t ." output setglobal COMPREPLY = ''( $( compgen -W 'ad a r d dd e' -- "$cur" ) ) return with -u # TODO: could be parsed from "-u ." output setglobal COMPREPLY = ''( $( compgen -W 's hms' -- "$cur" ) ) return with -W setglobal COMPREPLY = ''( $( compgen -W 'n' -- "$cur" ) ) return with -X if [[ $cur == lua_script:* ]] { setglobal cur = $(cur#*:) _filedir lua } else { setglobal COMPREPLY = ''( $( compgen -W 'lua_script:' -- "$cur" ) ) [[ $COMPREPLY == *: ]] && compopt -o nospace } return with -G setglobal COMPREPLY = ''( $( compgen -W "$( "$1" -G ? | \ awk '/^[ \t]*-G / \ { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }' )" \ -- "$cur" ) ) return } if [[ "$cur" == -* ]] { setglobal COMPREPLY = ''( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) return } } && complete -F _tshark tshark # ex: ts=4 sw=4 et filetype=sh