From 8cb465d3933a7836be78c3c16cccfd2e2e297eb1 Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Wed, 10 Jan 2001 23:09:48 +0000 Subject: [PATCH] added Red Hat service completion --- bash_completion | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index c3252bdd..0a74fc08 100644 --- a/bash_completion +++ b/bash_completion @@ -2,7 +2,7 @@ # # # @@ -1105,3 +1105,31 @@ _make() return 0 } complete -F _make -X '+($*|*.[cho])' make gmake pmake + +# Red Hat Linux service completion. This completes on a list of all available +# service scripts in the SysV init.d directory, followed by that script's +# available commands +# +_service() +{ + local cur sysvdir + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + [ -d /etc/rc.d/initi.d ] && sysvdir=/etc/rc.d/init.d \ + || sysvdir=/etc/init.d + + #[[ "$cur" == -* ]] && return 0 + if [ $COMP_CWORD = 1 ]; then + COMPREPLY=( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' $cur ) ) + else + COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \ + s/^.*Usage.*{\(.*\)}.*$/\1/p" \ + $sysvdir/${COMP_WORDS[1]}' $cur ) ) + fi + + return 0 +} +complete -F _service service