From d4d9f1f97f0fbf798eafbb5c1c1976c342605eb5 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 02:50:11 +0200 Subject: Add rc.d bash completion Signed-off-by: Sebastien Luttringer --- bash-completion | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 bash-completion (limited to 'bash-completion') diff --git a/bash-completion b/bash-completion new file mode 100644 index 0000000..3b0f464 --- /dev/null +++ b/bash-completion @@ -0,0 +1,18 @@ +# rc.d bash completion by Seblu + +_rc.d () +{ + local action="help list start stop reload restart" + local cur="${COMP_WORDS[COMP_CWORD]}" + local caction="${COMP_WORDS[1]}" + if ((${COMP_CWORD} == 1)); then + COMPREPLY=($(compgen -W "${action}" -- "$cur")) + elif [[ "$caction" == "help" || "$caction" == "list" ]]; then + COMPREPLY=() + elif ((${COMP_CWORD} > 1)); then + COMPREPLY=($( compgen -W "$(find /etc/rc.d -maxdepth 1 -type f -executable -printf '%f\n')" -- "$cur" )) + fi +} +complete -F _rc.d rc.d + +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3