summarylogtreecommitdiffstats
path: root/_sv
blob: 8a1de2063678523cf91250d5e44b1e128055d04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#compdef sv

# completion for runit sv(1)
# Christian Neukirchen <chneukirchen@gmail.com>
# runit 2.1.1, services in /var/service are completed by default

local ret=1 services

_arguments \
    '-v[verbose]' \
    '-w[wait]:seconds' \
    '1: :->cmds' \
    '*:: :->args' && ret=0

case $state in
cmds)
    _values "sv command" \
        status \
        up \
        down \
        once \
        pause cont hup alarm interrupt quit 1 2 term kill \
        exit
    # above allow one-character shortcuts, complete these
    [[ $words[CURRENT] = [sudopchaiq12tke] ]] ||
    _values "sv command" \
        start \
        stop \
        restart \
        shutdown \
        force-stop \
        force-reload \
        force-restart \
        force-shutdown \
        check
    ret=0;;
args)
    services=( /var/service/*(-/N:t) )
    (( $#services )) && _values services $services && ret=0
    [[ $words[CURRENT] = */* ]] && _directories && ret=0
    ;;
esac

return $ret