diff options
Diffstat (limited to 'contrib/bash-completion')
-rw-r--r-- | contrib/bash-completion | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/contrib/bash-completion b/contrib/bash-completion index d045844..f7273aa 100644 --- a/contrib/bash-completion +++ b/contrib/bash-completion @@ -1,14 +1,4 @@ -# netcfg completion by Maciej 'macieks' Sitarz <macieks@freesco.pl> - -_connected_prfls () -{ - COMPREPLY=( $( compgen -W "$( ls /run/network/profiles/ )" -- $cur ) ) -} - -_connected_intfs () -{ - COMPREPLY=( $( compgen -W "$( ls /run/network/interfaces/)" -- $cur ) ) -} +# netcfg completion _netcfg () { @@ -21,38 +11,40 @@ _netcfg () opts="-l -c -u -r -R -d -D -a -v -h" lopts="--help --version" cmds="list current check-iface up reconnect iface-recon down iface-down all-down all-suspend" - prfls="`find /etc/network.d -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' d -printf '%f\n'`" + prfls="$(find -L /etc/network.d/ -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' -printf '%f\n')" - case "${cur}" in - --*) - COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) ) + case "${prev}" in + -R|iface-recon|-D|iface-down) + COMPREPLY=( $( compgen -W "$(ls /run/network/interfaces/)" -- $cur ) ) return 0 ;; - -*) - COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) ) + -r|reconnect|-d|down) + COMPREPLY=( $( compgen -W "$(ls /run/network/profiles/)" -- $cur ) ) return 0 ;; - *) - if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $( compgen -W "${opts} ${lopts} ${cmds} ${prfls}" -- $cur ) ) - fi + -c|check-iface|-u|up) + COMPREPLY=( $( compgen -W "${prfls}" -- $cur ) ) + return 0 ;; esac - case "${prev}" in - -R|iface-recon|-D|iface-down) - _connected_intfs + case "${cur}" in + --*) + COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) ) return 0 ;; - -c|check-iface|-u|up|-r|reconnect|-d|down) - _connected_prfls + -*) + COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) ) return 0 ;; *) + ((COMP_CWORD == 1)) && \ + COMPREPLY=( $( compgen -W "${opts} ${lopts} ${cmds} ${prfls}" -- $cur ) ) ;; esac return 0 } + complete -F _netcfg netcfg complete -F _netcfg netcfg2 |