added Red Hat service completion

This commit is contained in:
ianmacd 2001-01-10 23:09:48 +00:00
parent af9b519c77
commit 8cb465d393

View File

@ -2,7 +2,7 @@
#
# <![CDATA[
#
# $Id: bash_completion,v 1.12 2000/12/20 03:04:54 ianmacd Exp $
# $Id: bash_completion,v 1.13 2001/01/11 00:09:48 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
@ -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