aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-06-18 04:08:43 +0200
committerSebastien Luttringer <seblu@seblu.net>2011-06-18 04:53:08 +0200
commit3b6e12a8ce903c93127914b1beb5b203b10e1547 (patch)
tree6371be0599871dad2b02e47d1cb3e1b09903f184
parentb1b7e18d21acb8a27912ea9e3bafef491fc16f63 (diff)
downloadinitscripts-3b6e12a8ce903c93127914b1beb5b203b10e1547.tar.xz
rc.d: Update bash and zsh completion scripts
Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
-rw-r--r--bash-completion8
-rw-r--r--zsh-completion5
2 files changed, 9 insertions, 4 deletions
diff --git a/bash-completion b/bash-completion
index 5151972..489b5dc 100644
--- a/bash-completion
+++ b/bash-completion
@@ -5,15 +5,17 @@ _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
+ if ((COMP_CWORD == 1)); then
COMPREPLY=($(compgen -W "${action}" -- "$cur"))
- elif [[ "$caction" =~ help|list ]]; then
+ elif [[ "$caction" == help ]]; then
COMPREPLY=()
+ elif [[ "$caction" == list ]]; then
+ ((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || 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
+ elif ((COMP_CWORD > 1)); then
COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort))
fi
}
diff --git a/zsh-completion b/zsh-completion
index f1b7165..e5c2850 100644
--- a/zsh-completion
+++ b/zsh-completion
@@ -15,9 +15,12 @@ _rc.d () {
curcontext="${curcontext%:*:*}:rc.d-${action}:"
case $action in
- list|help)
+ help)
_arguments "*: :"
;;
+ list)
+ _arguments "2: :(started stopped)"
+ ;;
start)
_arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))"
;;