diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2012-03-21 11:05:20 +0100 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2012-03-21 11:05:20 +0100 |
commit | 2a7aa9d913dfa2591592bf1b1e0e6a7cf8e63808 (patch) | |
tree | 410ff1f055ff8ab7e7f4b6662f0065c879ee2b81 /contrib/bash-completion | |
parent | 3ee71c470423848b8ce4d172047cd9260c5ce9cc (diff) | |
download | netctl-2a7aa9d913dfa2591592bf1b1e0e6a7cf8e63808.tar.gz netctl-2a7aa9d913dfa2591592bf1b1e0e6a7cf8e63808.tar.xz |
Revised bash completion
Bash completion does not deal properly with profile filenames that contain whitespace.
There are some minor tweaks in this commit as well, but those should be harmless.
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 |