fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
d835c5252
master
1# localization: tier3 2# 3# Helper functions for wireshark/tshark/dumpcap completion 4 5function __fish_wireshark_choices 6string replace -rf --'^\s*(\S+) \(?([^)]*)\)?$' '$1\t$2' $argv 7end 8 9function __fish_wireshark_interface 10# no remote capture yet 11command tshark -D2> /dev/null| string replace -r".*\. ( \S+ ) \s*\(?([^)]*)\)?\$" '$1\t$2' 12end 13 14function __fish_wireshark_protocol 15command tshark -G protocols2> /dev/null| awk -F\t '{print $3"\t"$1}' 16end 17 18function __fish_wireshark_heuristic 19command tshark -G heuristic-decodes2> /dev/null| awk -F\t '{print $2"\t"$1}' 20end 21 22function __fish_tshark_name_resolving_flags 23printf --( commandline -ct| string replace -r --'^-N' '' ) %s\n \ 24 d\t"enable resolution from captured DNS packets" \ 25 m\t"enable MAC address resolution" \ 26 n\t"enable network address resolution" \ 27 N\t"enable using external resolvers (such as DNS) for network address resolution" \ 28 t\t"enable transport-layer port number resolution" \ 29 v\t"enable VLAN IDs to names resolution" 30end 31 32function __fish_tshark_decode_as 33set -l tok( commandline -ct| string collect) 34if string match -rq --'==$' $tok 35return 36else if string match -rq --'(==|,)' $tok 37set -l tok_no_comma( string replace -r --',.*$' '' $tok ) 38command tshark -d( string replace -r --'^-d' '' $tok ) 2>| 39string replace -rf --"^\t ( \S+ ) \(?([^\)]*)\)?\$" " $tok_no_comma ,\$1\t\$2" 40else 41command tshark -d .2>| string replace -rf --"^\t ( \S+ ) \(?([^\)]*)\)?\$" '$1==\t$2' 42end 43end 44 45function __fish_complete_wireshark 46set -l shark$argv 47complete -c$shark -s a -l autostop -d'Specify a criterion to stop writing the capture file' -xa' 48duration:\t"Stop writing to capture files after N seconds have elapsed" 49files:\t"Stop writing to capture files after N files were written" 50filesize:\t"Stop writing a capture file after it reaches a size of N kB" 51packets:\t"Stop writing a capture file after it contains N packets"' 52complete -c$shark -s b -l ring-buffer -d'Write multiple capture files' -xa' 53duration:\t"Switch to the next file after N seconds have elapsed" 54files:\t"Begin again with the first file after N files were written" 55filesize:\t"Switch to the next file after it reaches a size of N kB" 56interval:\t"Switch to the next file when the time is an exact multiple of N seconds" 57packets:\t"Switch to the next file after it contains N packets"' 58complete -c$shark -s B -l buffer-size -d'Set capture buffer size (in MiB, default is 2 MiB)' -x 59complete -c$shark -s c -d'Set the maximum number of packets to read' -x 60complete -c$shark -l capture-comment -d'Add a capture comment to the output file' -x 61complete -c$shark -s D -l list-interfaces -d"Print a list of interfaces on which $shark can capture and exit" 62complete -c$shark -s f -d'Set a capture filter expression' -x 63complete -c$shark -s i -ra'(__fish_wireshark_interface)' 64complete -c$shark -s i -ra'-\t"Capture from standard input"' \ 65 -d'Network interface or pipe to use for live packet capture' 66complete -c$shark -s I -l monitor-mode -d'Put the interface in "monitor mode"' 67complete -c$shark -s L -l list-data-link-types -d'List the data link types supported by the interface and exit' 68complete -c$shark -l list-time-stamp-types -d'List time stamp types supported for the interface' 69complete -c$shark -s p -l no-promiscuous-mode -d"Don't put the interface into promiscuous mode" 70complete -c$shark -s s -l snapshot-length -d'Set the default snapshot length in bytes to use when capturing live data' -x 71complete -c$shark -l time-stamp-type -d"Change the interface's timestamp method" -xa'(__fish_wireshark_choices (command tshark --list-time-stamp-types 2>/dev/null))' 72complete -c$shark -s v -l version -d'Print the version and exit' 73complete -c$shark -s w -d'Write raw packet data to the given file ("-" means stdout)' -r 74complete -c$shark -s y -l linktype -d'Set the data link type to use while capturing packets' -xa'(__fish_wireshark_choices (command tshark -L 2>/dev/null))' 75 76switch $shark 77case dumpcap tshark 78complete -c tshark -s q -d"Don't display the continuous count of packets captured" 79complete -c tshark -s g -d'Create output files with greoup-read permissions' 80end 81 82switch $shark 83case wireshark tshark 84complete -c$shark -s C -d'Run with the given configuration profile' -xa'( 85set -l folders (tshark -G folders 2>/dev/null | awk \'/Personal configuration/{ print $NF}\')/profiles/* 86string match -r "[^/]*\\$" -- $folders)' 87complete -c$shark -s d -d'Specify how a layer type should be dissected' -xa'(__fish_tshark_decode_as)' 88complete -c$shark -l enable-protocol -d'Enable dissection of the given protocol' -xa'(__fish_wireshark_protocol)' 89complete -c$shark -l disable-protocol -d'Disable dissection of the given protocol' -xa'(__fish_wireshark_protocol)' 90complete -c$shark -l enable-heuristic -d'Enable dissection of heuristic protocol' -xa'(__fish_wireshark_heuristic)' 91complete -c$shark -l disable-heuristic -d'Disable dissection of heuristic protocol' -xa'(__fish_wireshark_heuristic)' 92complete -c$shark -s K -d'Load kerberos crypt keys from the specified keytab file' -r 93complete -c$shark -s n -d'Disable network object name resolution (hostname, TCP and UDP port names)' 94complete -c$shark -s N -d'Turn on name resolution only for particular types of addresses and port numbers' -xa'( __fish_tshark_name_resolving_flags)' 95complete -c$shark -s o -d'Override a preference value' -xa'( 96command tshark -G defaultprefs 2>/dev/null | string replace -rf -- \'^#([a-z].*):.*\' \'$1:\')' 97complete -c$shark -s r -l read-file -d'Read packet data from the given file' -r 98complete -c$shark -s R -l read-filter -d'Apply the given read filter' -x 99complete -c$shark -s t -d'Set the format of the packet timestamp printed in summary lines' -xa' 100a\t"absolute time" 101ad\t"absolute time with date" 102adoy\t"absolute time with date using day of year" 103d\t"delta: time since the previous packet was captured" 104dd\t"delta displayed: time since the previous displayed packet was captured" 105e\t"epoch: time in seconds since Jan 1, 1970" 106r\t"relative time elapsed between the first packet and the current packet" 107u\t"absolute UTC time" 108ud\t"absolute UTC time with date" 109udoy\t"absolute UTC time with date using day of year"' 110complete -c$shark -s u -d"Specifies the seconds type" -xa's\t"seconds" hms\t"hours, minutes and seconds"' 111complete -c$shark -s X -d"Specify an extension to be passed to a $shark module" -x# TODO 112complete -c$shark -s Y -l display-filter -d'Apply the given display filter' -x 113complete -c$shark -s z -d'Collect various types of statistics' -x# TODO 114end 115end