diff options
author | cyqsimon <28627918+cyqsimon@users.noreply.github.com> | 2023-08-25 19:11:27 +0800 |
---|---|---|
committer | cyqsimon <28627918+cyqsimon@users.noreply.github.com> | 2023-08-25 19:11:27 +0800 |
commit | dab19856704972d036252d101c754cc3fc2d85dc (patch) | |
tree | dfc6093d441f5d460017ea9a54e960ef5a1a7751 /completion/bandwhich | |
parent | ffbf0cd8aa73ed3db3e9dc01f154eacb5fe1130c (diff) |
Move completion file location
Diffstat (limited to 'completion/bandwhich')
-rw-r--r-- | completion/bandwhich | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/completion/bandwhich b/completion/bandwhich new file mode 100644 index 0000000..4b9cdff --- /dev/null +++ b/completion/bandwhich @@ -0,0 +1,31 @@ +# 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 |