From d543c7aa098c214fa5e55a497353dda47b95d3ad Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sat, 21 May 2011 21:12:28 +0200 Subject: rc.d bash completion detect running daemon This patch adds sexy features from Auguste Pop bash completion patch. Mainly, detect if a daemon is running and complete accordingly Signed-off-by: Sebastien Luttringer --- bash-completion | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash-completion b/bash-completion index 3b0f464..5151972 100644 --- a/bash-completion +++ b/bash-completion @@ -7,10 +7,14 @@ _rc.d () local caction="${COMP_WORDS[1]}" if ((${COMP_CWORD} == 1)); then COMPREPLY=($(compgen -W "${action}" -- "$cur")) - elif [[ "$caction" == "help" || "$caction" == "list" ]]; then + elif [[ "$caction" =~ help|list ]]; then COMPREPLY=() + elif [[ "$caction" == start ]]; then + COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) + elif [[ "$caction" =~ stop|restart|reload ]]; then + COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) elif ((${COMP_CWORD} > 1)); then - COMPREPLY=($( compgen -W "$(find /etc/rc.d -maxdepth 1 -type f -executable -printf '%f\n')" -- "$cur" )) + COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) fi } complete -F _rc.d rc.d -- cgit v1.2.3