mirror of
https://github.com/imsnif/bandwhich.git
synced 2026-02-09 01:59:18 +08:00
32 lines
888 B
Bash
32 lines
888 B
Bash
# bandwhich completion -*- shell-script -*-
|
|
|
|
_bandwhich()
|
|
{
|
|
local cur prev flags opts
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
flags="--addresses --connections --help --no-resolve
|
|
--processes --raw --show-dns --total-utilization --version"
|
|
opts="--dns-server --interface"
|
|
|
|
interfaces=$(ip link show | grep -o ": .*:" | sed 's/[: ]//g' | tr '\n' ' ')
|
|
case "${prev}" in
|
|
--interface)
|
|
COMPREPLY=( $(compgen -W "${interfaces}" -- "${cur}"))
|
|
return
|
|
;;
|
|
esac
|
|
|
|
case "${cur}" in
|
|
--interface)
|
|
COMPREPLY=( $(compgen -W "${interfaces}"))
|
|
;;
|
|
-*)
|
|
COMPREPLY=( $(compgen -W "${flags} ${opts}" -- "${cur}"))
|
|
;;
|
|
esac
|
|
} &&
|
|
|
|
complete -o nospace -F _bandwhich bandwhich
|