Skip to content

Commit 84f26c4

Browse files
committed
Add basic completion for 'iw'
1 parent 9039d77 commit 84f26c4

File tree

1 file changed

+127
-0
lines changed
  • completions

1 file changed

+127
-0
lines changed

completions/iw

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
_iw()
2+
{
3+
local cur prev words cword
4+
_init_completion || return
5+
6+
case $prev in
7+
--version)
8+
return
9+
;;
10+
esac
11+
12+
# find last word typed
13+
local subcword obj cmd
14+
for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do
15+
[[ ${words[subcword]} == '--version' ]] && return
16+
[[ -n $obj ]] && break
17+
[[ ${words[subcword]} != -* ]] && obj=${words[subcword]}
18+
done
19+
20+
21+
if [[ -z $obj ]]; then
22+
case $cur in
23+
-*)
24+
local c="--version --debug"
25+
COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
26+
return
27+
;;
28+
*)
29+
COMPREPLY=( $( compgen -W "$(iw | cut -d' ' -f1 | grep '^\s[^-]')" -- "$cur" ) )
30+
return
31+
;;
32+
esac
33+
fi
34+
35+
if [[ $obj == help ]]; then
36+
COMPREPLY=( $(compgen -W "ap cac channels coalesce cqm del disconnect get ibss info interface link mesh mpath mpp ocb offchannel p2p reg roc scan set station survey switch vendor wowlan" -- "$cur") )
37+
return
38+
fi
39+
40+
case $obj in
41+
dev)
42+
if [[ $prev == dev ]]; then
43+
_available_interfaces
44+
return
45+
fi
46+
case $(($cword-$subcword)) in
47+
1)
48+
COMPREPLY=( $(compgen -W "ap cac cqm del disconnect get ibss info interface link mesh mpath mpp ocb offchannel roc scan set station survey switch vendor" -- "$cur") )
49+
;;
50+
2)
51+
case $prev in
52+
ap)
53+
COMPREPLY=( $(compgen -W "start stop" -- "$cur") )
54+
;;
55+
cac)
56+
COMPREPLY=( $(compgen -W "channel freq trigger" -- "$cur") )
57+
;;
58+
cqm)
59+
COMPREPLY=( $(compgen -W "rssi" -- "$cur") )
60+
;;
61+
del)
62+
# TODO
63+
;;
64+
disconnect)
65+
;;
66+
get)
67+
COMPREPLY=( $(compgen -W "mesh_param power_save" -- "$cur") )
68+
;;
69+
ibss)
70+
COMPREPLY=( $(compgen -W "leave" -- "$cur") )
71+
;;
72+
info)
73+
return
74+
;;
75+
interface)
76+
COMPREPLY=( $(compgen -W "add" -- "$cur") )
77+
;;
78+
link)
79+
return
80+
;;
81+
mesh)
82+
COMPREPLY=( $(compgen -W "join leave" -- "$cur") )
83+
;;
84+
mpath)
85+
COMPREPLY=( $(compgen -W "del dump get new set" -- "$cur") )
86+
;;
87+
mpp)
88+
COMPREPLY=( $(compgen -W "dump get" -- "$cur") )
89+
;;
90+
ocb)
91+
COMPREPLY=( $(compgen -W "join leave" -- "$cur") )
92+
;;
93+
offchannel)
94+
# TODO
95+
;;
96+
roc)
97+
COMPREPLY=( $(compgen -W "start" -- "$cur") )
98+
;;
99+
scan)
100+
COMPREPLY=( $(compgen -W "abort dump sched_stop" -- "$cur") )
101+
;;
102+
set)
103+
# TODO
104+
COMPREPLY=( $(compgen -W "4addr channel freq mcast_rate meshid mesh_param monitor noack_map peer power_save txpower type" -- "$cur") )
105+
;;
106+
station)
107+
COMPREPLY=( $(compgen -W "del dump get set" -- "$cur") )
108+
;;
109+
survey)
110+
COMPREPLY=( $(compgen -W "dump" -- "$cur") )
111+
;;
112+
switch)
113+
COMPREPLY=( $(compgen -W "channel freq" -- "$cur") )
114+
;;
115+
vendor)
116+
COMPREPLY=( $(compgen -W "recv recvbin send" -- "$cur") )
117+
;;
118+
esac
119+
;;
120+
esac
121+
;;
122+
esac
123+
124+
} &&
125+
complete -F _iw iw
126+
127+
# ex: filetype=sh

0 commit comments

Comments
 (0)