Split {update,invoke}-rc.d completions to contrib/sysv-rc
This commit is contained in:
parent
b14fdb74b3
commit
4bf60b4e9a
1
CHANGES
1
CHANGES
@ -16,6 +16,7 @@ bash-completion (1.x)
|
|||||||
* Split mutt completion to contrib/mutt
|
* Split mutt completion to contrib/mutt
|
||||||
* Split iconv completion to contrib/iconv
|
* Split iconv completion to contrib/iconv
|
||||||
* Split dict completion to contrib/dict
|
* Split dict completion to contrib/dict
|
||||||
|
* Split {update,invoke}-rc.d completions to contrib/sysv-rc
|
||||||
|
|
||||||
[ Ville Skyttä ]
|
[ Ville Skyttä ]
|
||||||
* Split yum and yum-arch completion into contrib/yum.
|
* Split yum and yum-arch completion into contrib/yum.
|
||||||
|
@ -102,6 +102,7 @@ bashcomp_DATA = contrib/ant \
|
|||||||
contrib/_subversion \
|
contrib/_subversion \
|
||||||
contrib/svk \
|
contrib/svk \
|
||||||
contrib/sysctl \
|
contrib/sysctl \
|
||||||
|
contrib/sysv-rc \
|
||||||
contrib/tar \
|
contrib/tar \
|
||||||
contrib/tcpdump \
|
contrib/tcpdump \
|
||||||
contrib/unace \
|
contrib/unace \
|
||||||
|
107
bash_completion
107
bash_completion
@ -3237,113 +3237,6 @@ _id()
|
|||||||
} &&
|
} &&
|
||||||
complete -F _id id
|
complete -F _id id
|
||||||
|
|
||||||
# update-rc.d(8) completion
|
|
||||||
#
|
|
||||||
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
|
|
||||||
#
|
|
||||||
have update-rc.d &&
|
|
||||||
_update_rc_d()
|
|
||||||
{
|
|
||||||
local cur prev sysvdir services options valid_options
|
|
||||||
|
|
||||||
cur=`_get_cword`
|
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
||||||
|
|
||||||
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
|
||||||
|| sysvdir=/etc/init.d
|
|
||||||
|
|
||||||
services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm@(orig|new|save))) )
|
|
||||||
services=( ${services[@]#$sysvdir/} )
|
|
||||||
options=( -f -n )
|
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
|
|
||||||
valid_options=( $( \
|
|
||||||
echo "${COMP_WORDS[@]} ${options[@]}" \
|
|
||||||
| tr " " "\n" \
|
|
||||||
| sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
|
|
||||||
| sort | uniq -u \
|
|
||||||
) )
|
|
||||||
COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
|
|
||||||
-X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) )
|
|
||||||
elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W 'remove defaults start stop' -- $cur ) )
|
|
||||||
elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
|
|
||||||
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
|
|
||||||
elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
|
|
||||||
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
|
|
||||||
elif [[ "$prev" == defaults && -z "$cur" ]]; then
|
|
||||||
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
|
|
||||||
elif [[ "$prev" == ?(start|stop) ]]; then
|
|
||||||
if [[ "$cur" == [0-9] || -z "$cur" ]]; then
|
|
||||||
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
|
|
||||||
elif [[ "$cur" == [0-9][0-9] ]]; then
|
|
||||||
COMPREPLY=( $cur )
|
|
||||||
else
|
|
||||||
COMPREPLY=()
|
|
||||||
fi
|
|
||||||
elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
|
|
||||||
if [[ -z "$cur" ]]; then
|
|
||||||
if [[ $prev == [0-9][0-9] ]]; then
|
|
||||||
COMPREPLY=( 0 1 2 3 4 5 6 S )
|
|
||||||
else
|
|
||||||
COMPREPLY=( 0 1 2 3 4 5 6 S . )
|
|
||||||
fi
|
|
||||||
elif [[ "$cur" == [0-6S.] ]]; then
|
|
||||||
COMPREPLY=( $cur )
|
|
||||||
else
|
|
||||||
COMPREPLY=()
|
|
||||||
fi
|
|
||||||
elif [[ "$prev" == "." ]]; then
|
|
||||||
COMPREPLY=( $(compgen -W "start stop" -- $cur) )
|
|
||||||
else
|
|
||||||
COMPREPLY=()
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
} &&
|
|
||||||
complete -F _update_rc_d update-rc.d
|
|
||||||
|
|
||||||
# invoke-rc.d(8) completion
|
|
||||||
#
|
|
||||||
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
|
|
||||||
#
|
|
||||||
have invoke-rc.d &&
|
|
||||||
_invoke_rc_d()
|
|
||||||
{
|
|
||||||
local cur prev sysvdir services options valid_options
|
|
||||||
|
|
||||||
cur=`_get_cword`
|
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
||||||
|
|
||||||
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
|
||||||
|| sysvdir=/etc/init.d
|
|
||||||
|
|
||||||
services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm@(orig|new|save))) )
|
|
||||||
services=( ${services[@]#$sysvdir/} )
|
|
||||||
options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
|
|
||||||
|
|
||||||
if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
|
|
||||||
valid_options=( $( \
|
|
||||||
echo ${COMP_WORDS[@]} ${options[@]} \
|
|
||||||
| tr " " "\n" \
|
|
||||||
| sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
|
|
||||||
| sort | uniq -u \
|
|
||||||
) )
|
|
||||||
COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
|
|
||||||
$cur ) )
|
|
||||||
elif [ -x $sysvdir/$prev ]; then
|
|
||||||
COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
|
|
||||||
s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
|
|
||||||
$sysvdir/$prev`' -- \
|
|
||||||
$cur ) )
|
|
||||||
else
|
|
||||||
COMPREPLY=()
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
} &&
|
|
||||||
complete -F _invoke_rc_d invoke-rc.d
|
|
||||||
|
|
||||||
_filedir_xspec()
|
_filedir_xspec()
|
||||||
{
|
{
|
||||||
local IFS cur xspec
|
local IFS cur xspec
|
||||||
|
106
contrib/sysv-rc
Normal file
106
contrib/sysv-rc
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# update-rc.d(8) completion
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
|
||||||
|
#
|
||||||
|
have update-rc.d &&
|
||||||
|
_update_rc_d()
|
||||||
|
{
|
||||||
|
local cur prev sysvdir services options valid_options
|
||||||
|
|
||||||
|
cur=`_get_cword`
|
||||||
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
|
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
||||||
|
|| sysvdir=/etc/init.d
|
||||||
|
|
||||||
|
services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm@(orig|new|save))) )
|
||||||
|
services=( ${services[@]#$sysvdir/} )
|
||||||
|
options=( -f -n )
|
||||||
|
|
||||||
|
if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
|
||||||
|
valid_options=( $( \
|
||||||
|
echo "${COMP_WORDS[@]} ${options[@]}" \
|
||||||
|
| tr " " "\n" \
|
||||||
|
| sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
|
||||||
|
| sort | uniq -u \
|
||||||
|
) )
|
||||||
|
COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
|
||||||
|
-X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) )
|
||||||
|
elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W 'remove defaults start stop' -- $cur ) )
|
||||||
|
elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
|
||||||
|
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
|
||||||
|
elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
|
||||||
|
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
|
||||||
|
elif [[ "$prev" == defaults && -z "$cur" ]]; then
|
||||||
|
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
|
||||||
|
elif [[ "$prev" == ?(start|stop) ]]; then
|
||||||
|
if [[ "$cur" == [0-9] || -z "$cur" ]]; then
|
||||||
|
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
|
||||||
|
elif [[ "$cur" == [0-9][0-9] ]]; then
|
||||||
|
COMPREPLY=( $cur )
|
||||||
|
else
|
||||||
|
COMPREPLY=()
|
||||||
|
fi
|
||||||
|
elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
|
||||||
|
if [[ -z "$cur" ]]; then
|
||||||
|
if [[ $prev == [0-9][0-9] ]]; then
|
||||||
|
COMPREPLY=( 0 1 2 3 4 5 6 S )
|
||||||
|
else
|
||||||
|
COMPREPLY=( 0 1 2 3 4 5 6 S . )
|
||||||
|
fi
|
||||||
|
elif [[ "$cur" == [0-6S.] ]]; then
|
||||||
|
COMPREPLY=( $cur )
|
||||||
|
else
|
||||||
|
COMPREPLY=()
|
||||||
|
fi
|
||||||
|
elif [[ "$prev" == "." ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W "start stop" -- $cur) )
|
||||||
|
else
|
||||||
|
COMPREPLY=()
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
} &&
|
||||||
|
complete -F _update_rc_d update-rc.d
|
||||||
|
|
||||||
|
# invoke-rc.d(8) completion
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
|
||||||
|
#
|
||||||
|
have invoke-rc.d &&
|
||||||
|
_invoke_rc_d()
|
||||||
|
{
|
||||||
|
local cur prev sysvdir services options valid_options
|
||||||
|
|
||||||
|
cur=`_get_cword`
|
||||||
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
|
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
||||||
|
|| sysvdir=/etc/init.d
|
||||||
|
|
||||||
|
services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm@(orig|new|save))) )
|
||||||
|
services=( ${services[@]#$sysvdir/} )
|
||||||
|
options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
|
||||||
|
|
||||||
|
if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
|
||||||
|
valid_options=( $( \
|
||||||
|
echo ${COMP_WORDS[@]} ${options[@]} \
|
||||||
|
| tr " " "\n" \
|
||||||
|
| sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
|
||||||
|
| sort | uniq -u \
|
||||||
|
) )
|
||||||
|
COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
|
||||||
|
$cur ) )
|
||||||
|
elif [ -x $sysvdir/$prev ]; then
|
||||||
|
COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
|
||||||
|
s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
|
||||||
|
$sysvdir/$prev`' -- \
|
||||||
|
$cur ) )
|
||||||
|
else
|
||||||
|
COMPREPLY=()
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
} &&
|
||||||
|
complete -F _invoke_rc_d invoke-rc.d
|
Loading…
x
Reference in New Issue
Block a user