Files
bandwhich/completion/bandwhich
2023-08-25 19:11:27 +08:00

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