| 1 |
# netctl completion |
| 2 |
|
| 3 |
|
| 4 |
_wireless_interfaces() { |
| 5 |
local iface |
| 6 |
|
| 7 |
for iface in /sys/class/net/*/wireless/; do |
| 8 |
echo ${iface:15:-10} |
| 9 |
done |
| 10 |
} |
| 11 |
|
| 12 |
|
| 13 |
_netctl_profiles() { |
| 14 |
find -L /etc/netctl -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name $'*\n*' -not -name '*.action' -not -name '*.conf' -not -name '*.service' -printf '%f\n' |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
_netctl() { |
| 19 |
local cur=${COMP_WORDS[COMP_CWORD]} |
| 20 |
|
| 21 |
case $COMP_CWORD in |
| 22 |
1) |
| 23 |
COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to is-active status enable disable reenable is-enabled edit wait-online" -- "$cur") ) |
| 24 |
;; |
| 25 |
2) |
| 26 |
[[ ${COMP_WORDS[COMP_CWORD-1]} = @(start|stop|restart|switch-to|is-active|status|enable|disable|reenable|is-enabled|edit|wait-online) ]] && |
| 27 |
compopt -o filenames && |
| 28 |
mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur") |
| 29 |
;; |
| 30 |
esac |
| 31 |
} |
| 32 |
complete -F _netctl netctl |
| 33 |
|
| 34 |
|
| 35 |
_netctl_auto() { |
| 36 |
local cur=${COMP_WORDS[COMP_CWORD]} |
| 37 |
|
| 38 |
case $COMP_CWORD in |
| 39 |
1) |
| 40 |
COMPREPLY=( $(compgen -W "--help --version list switch-to is-active enable disable enable-all disable-all is-enabled" -- "$cur") ) |
| 41 |
;; |
| 42 |
2) |
| 43 |
[[ ${COMP_WORDS[COMP_CWORD-1]} = @(switch-to|is-active|enable|disable|is-enabled) ]] && |
| 44 |
compopt -o filenames && |
| 45 |
mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur") |
| 46 |
;; |
| 47 |
esac |
| 48 |
} |
| 49 |
complete -F _netctl_auto netctl-auto |
| 50 |
|
| 51 |
|
| 52 |
_wifi_menu() { |
| 53 |
(( COMP_CWORD == 1 )) && |
| 54 |
COMPREPLY=( $(compgen -W "$(_wireless_interfaces)" -- "${COMP_WORDS[1]}") ) |
| 55 |
} |
| 56 |
complete -F _wifi_menu wifi-menu |
| 57 |
|
| 58 |
|
| 59 |
# ex: ts=4 sw=4 et filetype=sh |