diff options
author | James Rayner <james@archlinux.org> | 2009-11-18 03:45:35 +0100 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2009-11-18 03:45:35 +0100 |
commit | 3cbb28408f4537fbc7beaa7148458f0db3f02baf (patch) | |
tree | fb3a3ee659f0bb6c828f162180a1a36f905b570d /contrib/bash-completion | |
parent | edf633af40487375d5c663ac217d42924214e130 (diff) | |
download | netctl-3cbb28408f4537fbc7beaa7148458f0db3f02baf.tar.gz netctl-3cbb28408f4537fbc7beaa7148458f0db3f02baf.tar.xz |
FS#13418,FS#12505 - add zsh/bash completion
Diffstat (limited to 'contrib/bash-completion')
-rw-r--r-- | contrib/bash-completion | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/contrib/bash-completion b/contrib/bash-completion new file mode 100644 index 0000000..44dd181 --- /dev/null +++ b/contrib/bash-completion @@ -0,0 +1,58 @@ +# netcfg completion by Maciej 'macieks' Sitarz <macieks@freesco.pl> + +_connected_prfls () +{ + COMPREPLY=( $( compgen -W "$( ls /var/run/network/profiles/ )" -- $cur ) ) +} + +_connected_intfs () +{ + COMPREPLY=( $( compgen -W "$( ls /var/run/network/interfaces/)" -- $cur ) ) +} + +_netcfg () +{ + local cur prev opts lopts cmds prfls + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="-c -d -a -i -h -v" + lopts="--help --version" + cmds="check-iface down all-down iface-down all-resume all-suspend" + prfls="`find /etc/network.d -maxdepth 1 -not -type d -printf '%f\n'`" + + case "${cur}" in + --*) + COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) ) + return 0 + ;; + -*) + COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) ) + return 0 + ;; + *) + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W "${opts} ${lopts} ${cmds} ${prfls}" -- $cur ) ) + fi + ;; + esac + + case "${prev}" in + -c|check-iface|-i|iface-down) + _connected_intfs + return 0 + ;; + -d|down) + _connected_prfls + return 0 + ;; + *) + ;; + esac + + return 0 +} +complete -F _netcfg netcfg +complete -F _netcfg netcfg2 |