summaryrefslogtreecommitdiffstats
path: root/completions/ip
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--completions/ip378
-rw-r--r--completions/ipcalc25
-rw-r--r--completions/iperf69
-rw-r--r--completions/ipmitool199
-rw-r--r--completions/ipsec102
-rw-r--r--completions/iptables51
-rw-r--r--completions/ipv6calc38
7 files changed, 862 insertions, 0 deletions
diff --git a/completions/ip b/completions/ip
new file mode 100644
index 0000000..12ad9aa
--- /dev/null
+++ b/completions/ip
@@ -0,0 +1,378 @@
+# ip(8) completion -*- shell-script -*-
+
+_iproute2_etc()
+{
+ COMPREPLY+=($(compgen -W \
+ "$(awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null)" \
+ -- "$cur"))
+}
+
+_ip()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ -V | -Version | -rc | -rcvbuf)
+ return
+ ;;
+ -f | -family)
+ COMPREPLY=($(compgen -W 'inet inet6 ipx dnet link' -- "$cur"))
+ return
+ ;;
+ -b | -batch)
+ _filedir
+ return
+ ;;
+ -force)
+ COMPREPLY=($(compgen -W '-batch' -- "$cur"))
+ return
+ ;;
+ esac
+
+ local subcword cmd subcmd=""
+ for ((subcword = 1; subcword < ${#words[@]} - 1; subcword++)); do
+ [[ ${words[subcword]} == -b?(atch) ]] && return
+ [[ -v cmd ]] && subcmd=${words[subcword]} && break
+ [[ ${words[subcword]} != -* && \
+ ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] &&
+ cmd=${words[subcword]}
+ done
+
+ if [[ ! -v cmd ]]; then
+ case $cur in
+ -*)
+ local c="-Version -statistics -details -resolve -family
+ -oneline -timestamp -batch -rcvbuf"
+ ((cword == 1)) && c+=" -force"
+ COMPREPLY=($(compgen -W "$c" -- "$cur"))
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "help $($1 help 2>&1 | command sed -e \
+ '/OBJECT := /,/}/!d' -e \
+ 's/.*{//' -e \
+ 's/}.*//' -e \
+ 's/|//g')" -- "$cur"))
+ ;;
+ esac
+ return
+ fi
+
+ [[ $subcmd == help ]] && return
+
+ case $cmd in
+ l | link)
+ case $subcmd in
+ add)
+ # TODO
+ ;;
+ delete)
+ case $((cword - subcword)) in
+ 1)
+ _available_interfaces
+ ;;
+ 2)
+ COMPREPLY=($(compgen -W 'type' -- "$cur"))
+ ;;
+ 3)
+ [[ $prev == type ]] &&
+ COMPREPLY=($(compgen -W 'vlan veth vcan dummy
+ ifb macvlan can' -- "$cur"))
+ ;;
+ esac
+ ;;
+ set)
+ if ((cword - subcword == 1)); then
+ _available_interfaces
+ else
+ case $prev in
+ arp | dynamic | multicast | allmulticast | promisc | \
+ trailers)
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ ;;
+ txqueuelen | name | address | broadcast | mtu | netns | alias) ;;
+
+ *)
+ local c="arp dynamic multicast allmulticast
+ promisc trailers txqueuelen name address
+ broadcast mtu netns alias"
+ [[ $prev != @(up|down) ]] && c+=" up down"
+ COMPREPLY=($(compgen -W "$c" -- "$cur"))
+ ;;
+ esac
+ fi
+ ;;
+ show)
+ if ((cword == subcword + 1)); then
+ _available_interfaces
+ COMPREPLY+=($(compgen -W 'dev group up' -- "$cur"))
+ elif [[ $prev == dev ]]; then
+ _available_interfaces
+ elif [[ $prev == group ]]; then
+ _iproute2_etc group
+ fi
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add delete set show' \
+ -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ a | addr | address)
+ case $subcmd in
+ add | change | replace)
+ if [[ $prev == dev ]]; then
+ _available_interfaces
+ elif [[ $prev == scope ]]; then
+ _iproute2_etc rt_scopes
+ else
+ : # TODO
+ fi
+ ;;
+ del)
+ if [[ $prev == dev ]]; then
+ _available_interfaces
+ elif [[ $prev == scope ]]; then
+ _iproute2_etc rt_scopes
+ else
+ : # TODO
+ fi
+ ;;
+ show | flush)
+ if ((cword == subcword + 1)); then
+ _available_interfaces
+ COMPREPLY+=($(compgen -W 'dev scope to label dynamic
+ permanent tentative deprecated dadfailed temporary
+ primary secondary up' -- "$cur"))
+ elif [[ $prev == dev ]]; then
+ _available_interfaces
+ elif [[ $prev == scope ]]; then
+ _iproute2_etc rt_scopes
+ fi
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add change replace del
+ show flush' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ addrlabel)
+ case $subcmd in
+ list | add | del | flush)
+ if [[ $prev == dev ]]; then
+ _available_interfaces
+ else
+ : # TODO
+ fi
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help list add del flush' \
+ -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ r | route)
+ case $subcmd in
+ list | flush)
+ if [[ $prev == proto ]]; then
+ _iproute2_etc rt_protos
+ else
+ : # TODO
+ fi
+ ;;
+ get)
+ # TODO
+ ;;
+ a | add | d | del | change | append | r | replace | monitor)
+ if [[ $prev == via ]]; then
+ COMPREPLY=($(compgen -W "$($1 r | command sed -ne \
+ 's/.*via \([0-9.]*\).*/\1/p')" -- "$cur"))
+ elif [[ $prev == "$subcmd" ]]; then
+ COMPREPLY=($(compgen -W "table default \
+ $($1 r | cut -d ' ' -f 1)" -- "$cur"))
+ elif [[ $prev == dev ]]; then
+ _available_interfaces -a
+ elif [[ $prev == table ]]; then
+ COMPREPLY=($(compgen -W 'local main default' -- "$cur"))
+ else
+ COMPREPLY=($(compgen -W 'via dev weight' -- "$cur"))
+ fi
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help list flush get add del
+ change append replace monitor' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ rule)
+ case $subcmd in
+ add | del | list | lst)
+ case $prev in
+ from | to | tos | dsfield | fwmark | uidrange | ipproto | sport | \
+ dport | priority | protocol | suppress_prefixlength | \
+ suppress_ifgroup | realms | nat | goto) ;;
+
+ iif | oif)
+ _available_interfaces -a
+ ;;
+ table | lookup)
+ COMPREPLY=($(compgen -W 'local main default' -- "$cur"))
+ ;;
+ *)
+ COMPREPLY=($(compgen -W 'from to tos dsfield fwmark
+ uidrange ipproto sport dport priority table lookup
+ protocol suppress_prefixlength suppress_ifgroup realms
+ nat goto iif oif not' -- "$cur"))
+ ;;
+ esac
+ ;;
+ flush | save)
+ if [[ $prev == protocol ]]; then
+ :
+ else
+ COMPREPLY=($(compgen -W 'protocol' -- "$cur"))
+ fi
+ ;;
+ restore | show) ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add del list flush save
+ restore show' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ neigh)
+ case $subcmd in
+ add | del | change | replace)
+ # TODO
+ ;;
+ show | flush)
+ # TODO
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add del change replace
+ show flush' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ ntable)
+ case $subcmd in
+ change)
+ # TODO
+ ;;
+ show)
+ # TODO
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help change show' \
+ -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ tunnel)
+ case $subcmd in
+ show) ;;
+
+ add | change | del | prl | 6rd)
+ # TODO
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add change del show prl
+ 6rd' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ maddr)
+ case $subcmd in
+ add | del)
+ # TODO
+ ;;
+ show)
+ if [[ $cword -eq $subcword+1 || $prev == dev ]]; then
+ _available_interfaces
+ [[ $prev != dev ]] &&
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]} dev' \
+ -- "$cur"))
+ fi
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add del show' \
+ -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ mroute)
+ case $subcmd in
+ show)
+ # TODO
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help show' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ monitor)
+ case $subcmd in
+ all) ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help all' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ netns)
+ case $subcmd in
+ list | monitor) ;;
+
+ add | identify | list-id)
+ # TODO
+ ;;
+ delete | exec | pids | set)
+ [[ $prev == "$subcmd" ]] &&
+ COMPREPLY=($(compgen -W "$($1 netns list)" -- "$cur"))
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'help add delete exec
+ identify list list-id monitor pids set' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ xfrm)
+ case $subcmd in
+ state | policy | monitor)
+ # TODO
+ ;;
+ *)
+ ((cword == subcword)) &&
+ COMPREPLY=($(compgen -W 'state policy monitor' \
+ -- "$cur"))
+ ;;
+ esac
+ ;;
+ esac
+} &&
+ complete -F _ip ip
+
+# ex: filetype=sh
diff --git a/completions/ipcalc b/completions/ipcalc
new file mode 100644
index 0000000..5603c26
--- /dev/null
+++ b/completions/ipcalc
@@ -0,0 +1,25 @@
+# ipcalc(1) completion -*- shell-script -*-
+
+_ipcalc()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ --help | --version | --split | -[hs])
+ return
+ ;;
+ esac
+
+ # --split takes 3 args
+ local i
+ for i in {1..3}; do
+ [[ ${words[cword - i]} == -@(-split|s) ]] && return
+ done
+
+ [[ $cur != -* ]] ||
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+} &&
+ complete -F _ipcalc ipcalc
+
+# ex: filetype=sh
diff --git a/completions/iperf b/completions/iperf
new file mode 100644
index 0000000..6347fe0
--- /dev/null
+++ b/completions/iperf
@@ -0,0 +1,69 @@
+# iperf(1) completion -*- shell-script -*-
+
+_iperf()
+{
+ local cur prev words cword split
+ _init_completion -s -n : || return
+
+ case $prev in
+ --help | --version | --interval | --len | --port | --window | --mss | --bandwidth | \
+ --num | --time | --listenport | --parallel | --ttl | --linux-congestion | --omit | \
+ --congestion | --bytes | --blockcount | --cport | --set-mss | --flowlabel | \
+ --title | --tos | --affinity | -!(-*)[hvilpwMbntLPTZCkOSA])
+ return
+ ;;
+ --format | -!(-*)f)
+ COMPREPLY=($(compgen -W 'k m g K M G' -- "$cur"))
+ return
+ ;;
+ --output | --fileinput | -!(-*)[oF])
+ _filedir
+ return
+ ;;
+ --bind | -!(-*)B)
+ _available_interfaces -a
+ _ip_addresses -a
+ __ltrim_colon_completions "$cur"
+ return
+ ;;
+ --client | -!(-*)c)
+ _known_hosts_real -- "$cur"
+ return
+ ;;
+ --reportexclude | -!(-*)x)
+ COMPREPLY=($(compgen -W 'C D M S V' -- "$cur"))
+ return
+ ;;
+ --reportstyle | -!(-*)y)
+ COMPREPLY=($(compgen -W 'C' -- "$cur"))
+ return
+ ;;
+ --logfile)
+ _filedir log
+ return
+ ;;
+ esac
+
+ $split && return
+
+ # Filter mode specific options
+ local i filter=cat
+ for i in "${words[@]}"; do
+ case $i in
+ -s | --server)
+ filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d'
+ ;;
+ -c | --client)
+ filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d'
+ ;;
+ esac
+ done
+ [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d'
+
+ COMPREPLY=($(compgen -W \
+ '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+} &&
+ complete -F _iperf iperf iperf3
+
+# ex: filetype=sh
diff --git a/completions/ipmitool b/completions/ipmitool
new file mode 100644
index 0000000..920287d
--- /dev/null
+++ b/completions/ipmitool
@@ -0,0 +1,199 @@
+# bash completion for ipmitool -*- shell-script -*-
+
+_ipmitool_singleline_help()
+{
+ COMPREPLY=($(compgen -W "$($1 $2 2>&1 |
+ command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur"))
+}
+
+_ipmitool()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ -*[hVpUekyPmbtBTl])
+ return
+ ;;
+ -*d)
+ COMPREPLY=($(compgen -W "$(
+ command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \
+ 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p'
+ )" \
+ -- "$cur"))
+ return
+ ;;
+ -*I)
+ COMPREPLY=($(compgen -W "$($1 -h 2>&1 |
+ command sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \
+ -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')" \
+ -- "$cur"))
+ return
+ ;;
+ -*H)
+ _known_hosts_real -- "$cur"
+ return
+ ;;
+ -*[fSO])
+ _filedir
+ return
+ ;;
+ -*C)
+ COMPREPLY=($(compgen -W '{0..14}' -- "$cur"))
+ return
+ ;;
+ -*L)
+ COMPREPLY=($(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \
+ -- "$cur"))
+ return
+ ;;
+ -*A)
+ COMPREPLY=($(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur"))
+ return
+ ;;
+ -*o)
+ COMPREPLY=($(compgen -W "$($1 -o list 2>&1 |
+ awk '/^[ \t]+/ { print $1 }') list" -- "$cur"))
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ return
+ fi
+
+ # Find out command and subcommand
+
+ local cmds=(raw i2c spd lan chassis power event mc sdr sensor fru gendev
+ sel pef sol tsol isol user channel session sunoem kontronoem picmg fwum
+ firewall shell exec set hpm ekanalyzer)
+ local i c cmd subcmd
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ [[ -v cmd ]] && subcmd=${words[i]} && break
+ for c in "${cmds[@]}"; do
+ [[ ${words[i]} == "$c" ]] && cmd=$c && break
+ done
+ done
+
+ if [[ ! -v cmd ]]; then
+ COMPREPLY=($(compgen -W '${cmds[@]}' -- "$cur"))
+ return
+ fi
+
+ # Command/subcommand completions
+
+ case $cmd in
+
+ shell) ;;
+
+ \
+ exec)
+ _filedir
+ ;;
+
+ chassis | power | kontronoem | fwum)
+ _ipmitool_singleline_help $1 $cmd
+ ;;
+
+ lan)
+ case $subcmd in
+ print | set) ;;
+
+ alert)
+ [[ $prev == alert ]] &&
+ COMPREPLY=($(compgen -W 'print set' -- "$cur"))
+ ;;
+ stats)
+ [[ $prev == stats ]] &&
+ COMPREPLY=($(compgen -W 'print set' -- "$cur"))
+ ;;
+ *)
+ COMPREPLY=($(compgen -W 'print set alert stats' \
+ -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ sdr)
+ case $subcmd in
+ get | info | type | list | entity) ;;
+
+ elist)
+ COMPREPLY=($(compgen -W 'all full compact event mclog fru
+ generic' -- "$cur"))
+ ;;
+ dump)
+ _filedir
+ ;;
+ fill)
+ case $prev in
+ fill)
+ COMPREPLY=($(compgen -W 'sensors file' -- "$cur"))
+ ;;
+ file)
+ _filedir
+ ;;
+ esac
+ ;;
+ *)
+ COMPREPLY=($(compgen -W 'get info type list elist entity
+ dump fill' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ sensor)
+ case $subcmd in
+ list | get | thresh) ;;
+
+ *)
+ COMPREPLY=($(compgen -W 'list get thresh' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ sel)
+ case $subcmd in
+ info | clear | list | elist | delete) ;;
+
+ add | save | writeraw | readraw)
+ _filedir
+ ;;
+ time)
+ [[ $prev == time ]] &&
+ COMPREPLY=($(compgen -W 'get set' -- "$cur"))
+ ;;
+ *)
+ COMPREPLY=($(compgen -W 'info clear list elist delete add
+ get save writeraw readraw time' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ user)
+ case $subcmd in
+ summary | list | disable | enable | priv | test) ;;
+
+ set)
+ [[ $prev == set ]] &&
+ COMPREPLY=($(compgen -W 'name password' -- "$cur"))
+ ;;
+ *)
+ COMPREPLY=($(compgen -W 'summary list set disable enable
+ priv test' -- "$cur"))
+ ;;
+ esac
+ ;;
+
+ set)
+ [[ $prev == set ]] &&
+ COMPREPLY=($(compgen -W 'hostname username password privlvl
+ authtype localaddr targetaddr port csv verbose' -- "$cur"))
+ ;;
+
+ esac
+} &&
+ complete -F _ipmitool ipmitool
+
+# ex: filetype=sh
diff --git a/completions/ipsec b/completions/ipsec
new file mode 100644
index 0000000..4bc8cdf
--- /dev/null
+++ b/completions/ipsec
@@ -0,0 +1,102 @@
+# Linux ipsec(8) completion (for FreeS/WAN and strongSwan) -*- shell-script -*-
+
+# Complete ipsec.conf conn entries.
+#
+# Reads a file from stdin in the ipsec.conf(5) format.
+_ipsec_connections()
+{
+ local keyword name
+ while read -r keyword name; do
+ if [[ $keyword == [#]* ]]; then continue; fi
+ [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=("$name")
+ done
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+}
+
+_ipsec_freeswan()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W 'auto barf eroute klipsdebug look manual
+ pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp
+ tncfg whack' -- "$cur"))
+ return
+ fi
+
+ case ${words[1]} in
+ auto)
+ COMPREPLY=($(compgen -W '--asynchronous --up --add --delete
+ --replace --down --route --unroute --ready --status
+ --rereadsecrets' -- "$cur"))
+ ;;
+ manual)
+ COMPREPLY=($(compgen -W '--up --down --route --unroute --union' \
+ -- "$cur"))
+ ;;
+ ranbits)
+ COMPREPLY=($(compgen -W '--quick --continuous --bytes' -- "$cur"))
+ ;;
+ setup)
+ COMPREPLY=($(compgen -W '--start --stop --restart' -- "$cur"))
+ ;;
+ *) ;;
+
+ esac
+}
+
+_ipsec_strongswan()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W 'down irdumm leases listaacerts listacerts
+ listalgs listall listcacerts listcainfos listcards listcerts
+ listcrls listgroups listocsp listocspcerts listpubkeys openac pki
+ pluto pool purgecerts purgecrls purgeike purgeocsp ready reload
+ rereadaacerts rereadacerts rereadall rereadcacerts rereadcrls
+ rereadgroups rereadocspcerts rereadsecrets restart route scdecrypt
+ scencrypt scepclient secrets start starter status statusall stop
+ stroke unroute uci up update version whack --confdir --copyright
+ --directory --help --version --versioncode' -- "$cur"))
+ return
+ fi
+
+ case ${words[1]} in
+ down | route | status | statusall | unroute | up)
+ local confdir=$(ipsec --confdir)
+ _ipsec_connections <"$confdir/ipsec.conf"
+ ;;
+ list*)
+ COMPREPLY=($(compgen -W '--utc' -- "$cur"))
+ ;;
+ restart | start)
+ COMPREPLY=($(compgen -W '--attach-gdb --auto-update --debug
+ --debug-all --debug-more --nofork' -- "$cur"))
+ ;;
+ pki)
+ COMPREPLY=($(compgen -W '--gen --issue --keyid --print --pub
+ --req --self --signcrl --verify' -- "$cur"))
+ ;;
+ pool) ;;
+
+ irdumm)
+ _filedir 'rb'
+ ;;
+ *) ;;
+
+ esac
+}
+
+case "$(ipsec --version 2>/dev/null)" in
+ *strongSwan*)
+ complete -F _ipsec_strongswan ipsec
+ ;;
+ *)
+ complete -F _ipsec_freeswan ipsec
+ ;;
+esac
+
+# ex: filetype=sh
diff --git a/completions/iptables b/completions/iptables
new file mode 100644
index 0000000..ffb905b
--- /dev/null
+++ b/completions/iptables
@@ -0,0 +1,51 @@
+# bash completion for iptables -*- shell-script -*-
+
+_iptables()
+{
+ local cur prev words cword split
+ _init_completion -s || return
+
+ local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
+
+ [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] &&
+ table="-t ${BASH_REMATCH[2]}"
+
+ case $prev in
+ -*[AIDRPFXLZ])
+ COMPREPLY=($(compgen -W '`"$1" $table -nL 2>/dev/null | \
+ command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur"))
+ ;;
+ -*t)
+ COMPREPLY=($(compgen -W 'nat filter mangle' -- "$cur"))
+ ;;
+ -j)
+ if [[ $table == "-t filter" || -z $table ]]; then
+ COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT
+ `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \
+ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
+ "$cur"))
+ elif [[ $table == "-t nat" ]]; then
+ COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT
+ DNAT MASQUERADE `"$1" $table -nL 2>/dev/null | \
+ command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
+ -- "$cur"))
+ elif [[ $table == "-t mangle" ]]; then
+ COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS
+ `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \
+ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
+ "$cur"))
+ fi
+ ;;
+ *)
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$("$1" --help 2>&1 |
+ command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ fi
+ ;;
+ esac
+
+} &&
+ complete -F _iptables iptables
+
+# ex: filetype=sh
diff --git a/completions/ipv6calc b/completions/ipv6calc
new file mode 100644
index 0000000..c452c15
--- /dev/null
+++ b/completions/ipv6calc
@@ -0,0 +1,38 @@
+# ipv6calc completion -*- shell-script -*-
+
+_ipv6calc()
+{
+ local cur prev words cword split
+ _init_completion -s || return
+
+ case "$prev" in
+ --debug | -!(-*)d)
+ return
+ ;;
+ --in | --out | --action | -!(-*)[IOA])
+ # With ipv6calc < 0.73.0, -m does nothing here, so use sed instead.
+ COMPREPLY=($(compgen -W "$($1 "$prev" -h 2>&1 |
+ command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')" \
+ -- "$cur"))
+ return
+ ;;
+ --db-geoip | --db-ip2location-ipv4 | --db-ip2location-ipv6)
+ _filedir
+ return
+ ;;
+ --printstart | --printend)
+ return
+ ;;
+ esac
+
+ $split && return
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$("$1" -h 2>&1 |
+ command sed -e "s/[][]//g" | _parse_help -)' -- "$cur"))
+ fi
+
+} &&
+ complete -F _ipv6calc ipv6calc
+
+# ex: filetype=sh