Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
59 - 1
# service(8) and /etc/init.d/* completion
2
 
3
# This completes on a list of all available service scripts for the
4
# 'service' command and/or the SysV init.d directory, followed by
5
# that script's available commands
6
#
7
{ have service || [ -d /etc/init.d/ ]; } &&
8
_service()
9
{
10
    local cur prev sysvdir
11
 
12
    COMPREPLY=()
13
    _get_comp_words_by_ref cur prev
14
 
15
    # don't complete for things like killall, ssh and mysql if it's
16
    # the standalone command, rather than the init script
17
    [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|?(*/)service) ]] && return 0
18
 
19
    # don't complete past 2nd token
20
    [ $COMP_CWORD -gt 2 ] && return 0
21
 
22
    if [[ $COMP_CWORD -eq 1 && $prev == ?(*/)service ]]; then
23
        _services
24
    else
25
        [ -d /etc/rc.d/init.d ] && \
26
            sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
27
        COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
28
            -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
29
            $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) )
30
    fi
31
 
32
    return 0
33
} &&
34
complete -F _service service
35
for svc in /etc/init.d/*; do
36
    [ ! -x "$svc" ] || complete -p "${svc##*/}" &>/dev/null || \
37
        complete -F _service -o default "${svc##*/}"
38
done
39
unset svc
40
 
41
# Local variables:
42
# mode: shell-script
43
# sh-basic-offset: 4
44
# sh-indent-comment: t
45
# indent-tabs-mode: nil
46
# End:
47
# ex: ts=4 sw=4 et filetype=sh