Skip to content

Commit 3c2cac0

Browse files
authored
Merge pull request #866 from steelman/brctl
brctl improvements
2 parents e162e5c + b5ae4eb commit 3c2cac0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

completions/brctl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# bash completion for brctl -*- shell-script -*-
22

3+
_comp_cmd_brctl__interfaces()
4+
{
5+
_comp_compgen_split -- "$(${1:-brctl} show ${2:+"$2"} 2>/dev/null | _comp_awk \
6+
'(NR == 1) { next }; (/^\t/) { print $1; next }; { print $4 }')"
7+
}
8+
39
_comp_cmd_brctl()
410
{
511
local cur prev words cword comp_args
@@ -15,18 +21,21 @@ _comp_cmd_brctl()
1521
;;
1622
2)
1723
case $command in
18-
show) ;;
24+
addbr) ;;
1925

2026
*)
2127
_comp_compgen_split -- "$("$1" show |
22-
_comp_awk 'NR>1 {print $1}')"
28+
_comp_awk '(NR>1 && !/^\t/) {print $1}')"
2329
;;
2430
esac
2531
;;
2632
3)
2733
case $command in
28-
addif | delif)
29-
_comp_compgen_configured_interfaces
34+
addif)
35+
_comp_compgen_available_interfaces
36+
;;
37+
delif)
38+
_comp_cmd_brctl__interfaces "$1" "$prev"
3039
;;
3140
stp)
3241
_comp_compgen -- -W 'on off'
@@ -35,6 +44,6 @@ _comp_cmd_brctl()
3544
;;
3645
esac
3746
} &&
38-
complete -F _comp_cmd_brctl -o default brctl
47+
complete -F _comp_cmd_brctl brctl
3948

4049
# ex: filetype=sh

0 commit comments

Comments
 (0)