# netctl completion _wireless_interfaces() { local iface for iface in /sys/class/net/*/wireless/; do echo ${iface:15:-10} done } _netctl_profiles() { 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' } _netctl() { local cur=${COMP_WORDS[COMP_CWORD]} case $COMP_CWORD in 1) 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") ) ;; 2) [[ ${COMP_WORDS[COMP_CWORD-1]} = @(start|stop|restart|switch-to|is-active|status|enable|disable|reenable|is-enabled|edit|wait-online) ]] && compopt -o filenames && mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur") ;; esac } complete -F _netctl netctl _netctl_auto() { local cur=${COMP_WORDS[COMP_CWORD]} case $COMP_CWORD in 1) COMPREPLY=( $(compgen -W "--help --version list switch-to is-active enable disable enable-all disable-all is-enabled" -- "$cur") ) ;; 2) [[ ${COMP_WORDS[COMP_CWORD-1]} = @(switch-to|is-active|enable|disable|is-enabled) ]] && compopt -o filenames && mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur") ;; esac } complete -F _netctl_auto netctl-auto _wifi_menu() { (( COMP_CWORD == 1 )) && COMPREPLY=( $(compgen -W "$(_wireless_interfaces)" -- "${COMP_WORDS[1]}") ) } complete -F _wifi_menu wifi-menu # ex: ts=4 sw=4 et filetype=sh