aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-05-21 19:12:28 (GMT)
committerSebastien Luttringer <seblu@seblu.net>2011-05-22 16:15:33 (GMT)
commitd543c7aa098c214fa5e55a497353dda47b95d3ad (patch)
treeb0a833eec41d8b1aa39c33be522e295ea3e3d2a1
parentd4d9f1f97f0fbf798eafbb5c1c1976c342605eb5 (diff)
downloadinitscripts-d543c7aa098c214fa5e55a497353dda47b95d3ad.tar.xz
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 <seblu@seblu.net>
-rw-r--r--bash-completion8
1 files 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