summaryrefslogtreecommitdiff
path: root/bash-completion
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2011-09-08 01:02:06 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2011-09-08 01:02:06 -0300
commitede246d73091a7b733ae56819fc7296e18aa4c31 (patch)
treed9913f474acc8d023605c90ba088d1b84ef3275a /bash-completion
parente70da9aade583714d399adb35573aecbea84f5f7 (diff)
parent7cccf54fcb9fab459590b8b6fd5c51f2088e3b2e (diff)
Merge branch 'master' of git://projects.archlinux.org/initscripts2011.09.8
Conflicts: functions
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion22
1 files changed, 12 insertions, 10 deletions
diff --git a/bash-completion b/bash-completion
index 5151972..d78484e 100644
--- a/bash-completion
+++ b/bash-completion
@@ -1,22 +1,24 @@
# rc.d bash completion by Seblu <seblu@seblu.net>
-_rc.d ()
+_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
+ local action cur prev
+ action="help list start stop reload restart"
+ _get_comp_words_by_ref cur prev
+ if ((COMP_CWORD == 1)); then
COMPREPLY=($(compgen -W "${action}" -- "$cur"))
- elif [[ "$caction" =~ help|list ]]; then
+ elif [[ "$prev" == help ]]; then
COMPREPLY=()
- elif [[ "$caction" == start ]]; then
+ elif [[ "$prev" == list ]]; then
+ ((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || COMPREPLY=()
+ elif [[ "$prev" == 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
+ elif [[ "$prev" =~ 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
}
-complete -F _rc.d rc.d
+complete -F _rc_d rc.d
# vim: set ts=2 sw=2 ft=sh noet: