Skip to content

Commit

Permalink
Merge pull request #866 from steelman/brctl
Browse files Browse the repository at this point in the history
brctl improvements
  • Loading branch information
scop authored Dec 29, 2024
2 parents e162e5c + b5ae4eb commit 3c2cac0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions completions/brctl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# bash completion for brctl -*- shell-script -*-

_comp_cmd_brctl__interfaces()
{
_comp_compgen_split -- "$(${1:-brctl} show ${2:+"$2"} 2>/dev/null | _comp_awk \
'(NR == 1) { next }; (/^\t/) { print $1; next }; { print $4 }')"
}

_comp_cmd_brctl()
{
local cur prev words cword comp_args
Expand All @@ -15,18 +21,21 @@ _comp_cmd_brctl()
;;
2)
case $command in
show) ;;
addbr) ;;

*)
_comp_compgen_split -- "$("$1" show |
_comp_awk 'NR>1 {print $1}')"
_comp_awk '(NR>1 && !/^\t/) {print $1}')"
;;
esac
;;
3)
case $command in
addif | delif)
_comp_compgen_configured_interfaces
addif)
_comp_compgen_available_interfaces
;;
delif)
_comp_cmd_brctl__interfaces "$1" "$prev"
;;
stp)
_comp_compgen -- -W 'on off'
Expand All @@ -35,6 +44,6 @@ _comp_cmd_brctl()
;;
esac
} &&
complete -F _comp_cmd_brctl -o default brctl
complete -F _comp_cmd_brctl brctl

# ex: filetype=sh

0 comments on commit 3c2cac0

Please sign in to comment.