summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-12-28 02:43:13 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2012-12-28 02:57:35 +0100
commit27c11787d7c58b02f12d7afd476ea66abfeecaaf (patch)
treee203812a9e6d2a901568ca36de3b1fc7380a369b /contrib
parent4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d (diff)
downloadnetctl-27c11787d7c58b02f12d7afd476ea66abfeecaaf.tar.gz
netctl-27c11787d7c58b02f12d7afd476ea66abfeecaaf.tar.xz
Forking netcfg to netctl (2/2)
This commit contains the refactoring and rewriting of code.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/bash-completion63
1 files changed, 22 insertions, 41 deletions
diff --git a/contrib/bash-completion b/contrib/bash-completion
index dab52ea..b47d92b 100644
--- a/contrib/bash-completion
+++ b/contrib/bash-completion
@@ -1,49 +1,30 @@
-# netcfg completion
+# netctl completion
-_netcfg ()
+_netctl()
{
- local cur prev opts lopts cmds prfls
+ local cur prev prof
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
+ 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")
- 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 -L /etc/network.d/ -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' -printf '%f\n')"
-
- case "${prev}" in
- -R|iface-recon|-D|iface-down)
- COMPREPLY=( $( compgen -W "$(ls /run/network/interfaces/)" -- $cur ) )
- return 0
- ;;
- -r|reconnect|-d|down)
- COMPREPLY=( $( compgen -W "$(ls /run/network/profiles/)" -- $cur ) )
- return 0
- ;;
- -c|check-iface|-u|up)
- COMPREPLY=( $( compgen -W "${prfls}" -- $cur ) )
- return 0
- ;;
- esac
-
- case "${cur}" in
- --*)
- COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
- return 0
- ;;
- -*)
- COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
- return 0
- ;;
- *)
- ((COMP_CWORD == 1)) && \
- COMPREPLY=( $( compgen -W "${opts} ${lopts} ${cmds} ${prfls}" -- $cur ) )
+ 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
- return 0
-}
-complete -F _netcfg netcfg
+# ex: ts=4 sw=4 et filetype=sh