# netctl completion _netctl() { local cur prev prof cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} prof=$(find -L /etc/network.d -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n") case $COMP_CWORD in 1) COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable reenable" -- $cur) ) ;; 2) case $prev in start|stop|restart|switch-to|status|enable|disable|reenable) mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$prof" -- $cur) ;; esac ;; *) COMPREPLY=() ;; esac } && complete -F _netctl netctl # ex: ts=4 sw=4 et filetype=sh