1
# ip(8) completion -*- shell-script -*-
5
local cur prev words cword
6
_init_completion || return
9
-V|-Version|-rc|-rcvbuf)
13
COMPREPLY=( $( compgen -W 'inet inet6 ipx dnet link' -- "$cur" ) )
21
COMPREPLY=( $( compgen -W '-batch' -- "$cur" ) )
26
local subcword cmd subcmd
27
for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do
28
[[ ${words[subcword]} == -b?(atch) ]] && return 0
29
[[ -n $cmd ]] && subcmd=${words[subcword]} && break
30
[[ ${words[subcword]} != -* && \
31
${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && \
32
cmd=${words[subcword]}
35
if [[ -z $cmd ]]; then
38
local c="-Version -statistics -details -resolve -family
39
-oneline -timestamp -batch -rcvbuf"
40
[[ $cword -eq 1 ]] && c+=" -force"
41
COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
45
COMPREPLY=( $( compgen -W "help $( ip help 2>&1 | \
46
sed -e '/OBJECT := /,/}/!d' \
47
-e 's/.*{//' -e 's/}.*//' -e 's/|//g' )" -- "$cur" ) )
53
[[ $subcmd == help ]] && return 0
62
case $(($cword-$subcword)) in
67
COMPREPLY=( $( compgen -W 'type' -- "$cur" ) )
70
[[ $prev == type ]] && \
71
COMPREPLY=( $( compgen -W 'vlan veth vcan dummy
72
ifb macvlan can' -- "$cur" ) )
77
if [[ $cword-$subcword -eq 1 ]]; then
81
arp|dynamic|multicast|allmulticast|promisc|\
83
COMPREPLY=( $( compgen -W 'on off' \
86
txqueuelen|name|address|broadcast|mtu|netns|alias)
89
local c="arp dynamic multicast allmulticast
90
promisc trailers txqueuelen name address
91
broadcast mtu netns alias"
92
[[ $prev != @(up|down) ]] && c+=" up down"
93
COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
99
[[ $cword -eq $subcword+1 ]] && _available_interfaces
102
[[ $cword -eq $subcword ]] && \
103
COMPREPLY=( $( compgen -W 'help add delete set show' \
121
[[ $cword -eq $subcword ]] && \
122
COMPREPLY=( $( compgen -W 'help add change replace del
123
show flush' -- "$cur" ) )
134
[[ $cword -eq $subcword ]] && \
135
COMPREPLY=( $( compgen -W 'help list add del flush' \
149
add|del|change|append|replace|monitor)
153
[[ $cword -eq $subcword ]] && \
154
COMPREPLY=( $( compgen -W 'help list flush get add del
155
change append replace monitor' -- "$cur" ) )
166
[[ $cword -eq $subcword ]] && \
167
COMPREPLY=( $( compgen -W 'help list add del flush' \
175
add|del|change|replace)
182
[[ $cword -eq $subcword ]] && \
183
COMPREPLY=( $( compgen -W 'help add del change replace
184
show flush' -- "$cur" ) )
198
[[ $cword -eq $subcword ]] && \
199
COMPREPLY=( $( compgen -W 'help change show' \
207
add|change|del|show|prl|6rd)
211
[[ $cword -eq $subcword ]] && \
212
COMPREPLY=( $( compgen -W 'help add change del show prl
224
if [[ $cword -eq $subcword+1 || $prev == dev ]]; then
225
_available_interfaces
226
[[ $prev != dev ]] && \
227
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} dev' \
232
[[ $cword -eq $subcword ]] && \
233
COMPREPLY=( $( compgen -W 'help add del show' \
245
[[ $cword -eq $subcword ]] && \
246
COMPREPLY=( $( compgen -W 'help show' -- "$cur" ) )
255
[[ $cword -eq $subcword ]] && \
256
COMPREPLY=( $( compgen -W 'help all' -- "$cur" ) )
263
state|policy|monitor)
267
[[ $cword -eq $subcword ]] && \
268
COMPREPLY=( $( compgen -W 'state policy monitor' \
277
# ex: ts=4 sw=4 et filetype=sh