fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a9618477e
master
1# iw(8) completion for fish 2 3# The completions for iw are based off those for ip, which has a similar options structure. 4 5set -l iw_commands dev phy reg event features commands list 6# wdev not supported since it is barely documented 7 8function __fish_iw_device 9__fish_print_interfaces | while read -l i 10printf '%s\t%s\n' $i Device 11end 12end 13 14function __fish_iw_phy 15set -l phys /sys/class/ieee80211/* 16string match --regex'[^/]*$' $phys 17end 18 19function __fish_iw_ssid 20printf '%s\n' ( iw dev$argv [ 1 ] scan dump| string match --regex --entire SSID| string split' ' )[ 2 ] 21end 22 23function __fish_complete_iw 24set -l cmd( commandline -xpc) 25 26if string match --quiet --'-*' $cmd [ 2 ] 27set -e cmd[ 2 ] # Allow other completions to complete as normal 28end 29if not set -q cmd[ 2 ] 30return # Uses completions from $iw_commands 31else if not set -q cmd[ 3 ] 32switch $cmd [ 2 ] 33case dev 34__fish_iw_device 35case phy 36__fish_iw_phy 37end 38return 39end 40switch $cmd [ 2 ] 41case dev 42switch " $cmd [ 4 ] " 43case ap 44if not set -q cmd[ 5 ] 45printf '%s\t%s\n' stop"Stop AP functionality" \ 46 start"Start AP functionality" 47end 48case auth connect 49if not set -q cmd[ 5 ] 50__fish_iw_ssid $cmd [ 3 ] 51end 52case disconnect 53case cqm 54if not set -q cmd[ 5 ] 55echo rssi 56else if not set -q cmd[ 6 ] 57echo threshold 58echo off 59end 60case ftm 61if not set -q cmd[ 5 ] 62printf '%s\t%s\n' start_responder"Start an FTM responder" \ 63 get_stats"Get FTM responder statistics" 64end 65case ibss 66if not set -q cmd[ 5 ] 67printf '%s\t%s\n' join"Join an IBSS cell or create one" \ 68 leave"Leave the current IBSS cell" 69end 70case switch 71if not set -q cmd[ 5 ] 72echo channel 73echo freq 74end 75case info del 76case interface 77if not set -q cmd[ 5 ] 78echo add 79end 80case link 81case measurement 82if not set -q cmd[ 5 ] 83echo ftm_request 84else if not set -q cmd[ 6 ] 85__fish_complete_path 86end 87# options after config file? 88case mesh 89if not set -q cmd[ 5 ] 90printf '%s\t%s\n' leave"Leave a mesh" \ 91 join"Join a mesh" 92end 93case mgmt 94if not set -q cmd[ 5 ] 95echo dump 96else if not set -q cmd[ 6 ] 97echo frame 98end 99case mpath 100if not set -q cmd[ 5 ] 101printf '%s\t%s\n' dump"List known mesh paths" \ 102 set"Set an existing mesh path's next hop" \ 103 new"Create a new mesh math manually" \ 104 del"Remove the mesh path to a node" \ 105 get"Get information on a mesh path to a node" \ 106 probe"Inject ethernet frame to a peer" 107end 108case mpp 109if not set -q cmd[ 5 ] 110printf '%s\t%s\n' dump"List known mesh proxy paths" \ 111 get"Get information on mesh proxy path to a node" 112end 113case ocb 114if not set -q cmd[ 5 ] 115printf '%s\t%s\n' leave"Leave the OCB mode network" \ 116 join"Join the OCB mode network" 117end 118case cac 119if not set -q cmd[ 5 ] 120echo channel 121echo freq 122echo trigger 123end 124case roc 125if not set -q cmd[ 5 ] 126echo start 127end 128case scan 129if not set -q cmd[ 5 ] 130printf '%s\t%s\n' sched_stop"Stop an ongoing scheduled scan" \ 131 sched_start"Start a scheduled scan" \ 132 abort"Abort ongoing scan" \ 133 trigger"Trigger a scan" \ 134 dump"Dmp the current scan results" 135end 136# -u option? 137case set 138if not set -q cmd[ 5 ] 139printf '%s\t%s\n' bitrates"Rate masks" \ 140 mcast_rate"Multicast bitrate" \ 141 peer"WDS peer" \ 142 noack_map"Noack map for TIDs" \ 143 4addr"4addr (WDS) mode" \ 144 type"Interface type/mode" \ 145 meshid"" \ 146 monitor"Monitor flags" \ 147 mesh_param"Mesh parameter" \ 148 txpower"Transmit power" \ 149 channel"" \ 150 freq"" \ 151 power_save"Power save state" 152else 153switch " $cmd [ 5 ] " 154case type 155if not set -q cmd[ 6 ] 156printf '%s\n' managed ibss monitor mesh wds 157end 158case channel 159if not set -q cmd[ 6 ] 160# cmd[6] is just the simple channel number 161else if not set -q cmd[ 7 ] 162printf '%s\n' NOHT HT20 HT40+ HT40- 5MHz 10MHz 80MHz 160MHz 163end 164end 165end 166case get 167if not set -q cmd[ 5 ] 168printf '%s\t%s\n' mesh_param"Mesh parameter" \ 169 power_save"Power save state" 170end 171case station 172if not set -q cmd[ 5 ] 173printf '%s\t%s\n' dump"List all stations known" \ 174 set"Set station options" \ 175 del"Remove a station entry" \ 176 get"Get information for a station" 177end 178case survey 179if not set -q cmd[ 5 ] 180echo dump 181end 182case vendor 183if not set -q cmd[ 5 ] 184echo recvbin 185echo recv 186echo send 187end 188case '*' 189printf '%s\t%s\n' ap"Start/stop AP functionality" \ 190 auth"Authenticate with a network" \ 191 connect"Join a network" \ 192 disconnect"Disconnect from the current network" \ 193 cqm"Set connection quality monitor RSSI threshold" \ 194 ftm"Control the FTM responder" \ 195 ibss"Join or leave a IBSS cell" \ 196 switch"Switch the operating channel by sending a CSA" \ 197 info"Show information for this interface" \ 198 del"Remove this virtual interface" \ 199 interface"Control the interface" \ 200 link"Print information about the current link" \ 201 measurement"Perform measurements" \ 202 mesh"Join or leave a mesh" \ 203 mpp"Get information on mesh proxy paths" \ 204 mgmt"Print mgmt frames" \ 205 mpath"Interact with mesh paths" \ 206 ocb"Join or leave an OCB mode network" \ 207 offchannel"Leave operating channel" \ 208 cac"Start or trigger a channel availability chec" \ 209 roc"" \ 210 scan"Scan and probe for SSIDs" \ 211 set"Set parameters" \ 212 get"Get parameters" \ 213 station"Set station parameters" \ 214 survey"List all gathered channel survey data" \ 215 vendor"" 216end 217case phy 218switch " $cmd [ 4 ] " 219case coalesce 220if not set -q cmd[ 5 ] 221printf '%s\t%s\n' show"Show coalesce status" \ 222 disable"Disable coalesce" \ 223 enable"Enable coalesce" 224else if test " $cmd [ 5 ] " = enable&& not set -q cmd[ 6 ] 225__fish_complete_path # Enable takes a config file 226end 227case hwsim 228if not set -q cmd[ 5 ] 229printf '%s\n' wakequeues stopqueues setps getps 230end 231case info 232case interface 233if not set -q cmd[ 5 ] 234echo add 235end 236case channels 237case reg 238if not set -q cmd[ 5 ] 239printf '%s\t%s\n' get"Print the current regulatory domain information" \ 240 set"Notify kernel about current regulatory domain" 241end 242case set 243if not set -q cmd[ 5 ] 244printf '%s\t%s\n' txq"TXQ parameters" \ 245 antenna"Bitmap of allowed antennas" \ 246 txpower"Transmit power" \ 247 distance"Link distance coverage class" \ 248 netns"Network namespace" \ 249 retry"Retry limit" \ 250 rts"Rts threshold" \ 251 frag"Fragmentation threshold" \ 252 channel"" \ 253 name"Wireless device name" 254end 255case get 256if not set -q cmd[ 5 ] 257printf '%s\t%s\n' txq"TXQ parameters" 258end 259case get 260if not set -q cmd[ 5 ] 261printf '%s\t%s\n' show"Show WoWLAN status" \ 262 disable"Disable WoWLAN" \ 263 enable"Enable WoWLAN" 264end 265case '*' 266printf '%s\t%s\n' coalesce"Interface with coalesce" \ 267 hwsim"" \ 268 info"Show wireless device capabilities" \ 269 interface"Add a new virtual interface" \ 270 channels"Show available channels" \ 271 reg"Manage regulatory domains" \ 272 set"Set parameters" \ 273 get"Get parameters" 274end 275end 276end 277 278complete -f -c iw 279complete -f -c iw -a'(__fish_complete_iw)' 280complete -f -c iw -n"not __fish_seen_subcommand_from $iw_commands " -a" $iw_commands " 281# Yes, iw only takes options before "objects" 282complete -f -c iw -l debug -d"Enable netlink message debugging" -n"not __fish_seen_subcommand_from $iw_commands " 283complete -f -c iw -l version -d"Print the version" -n"not __fish_seen_subcommand_from $iw_commands " 284 285complete -f -c iw -n"__fish_seen_subcommand_from event" -s t -d'Print timestamp' 286complete -f -c iw -n"__fish_seen_subcommand_from event" -s r -d'Print relative timestamp' 287complete -f -c iw -n"__fish_seen_subcommand_from event" -s f -d'Print full frame for auth/assoc' 288 289complete -f -c iw -n"__fish_seen_subcommand_from reg" -a reload -d'Reload the kernel\'s regulatory database' 290complete -f -c iw -n"__fish_seen_subcommand_from reg" -a get -d'Print the kernel\'s current regulatory domain information' 291complete -f -c iw -n"__fish_seen_subcommand_from reg" -a set -d'Notify the kernel about the current regulatory domain'