fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Daniel Rainerformat: use 4-space indents in more filesc5e4fed02

master
3.7 KiB75 linesraw
1# Completions for sv
2# A part of the runit init system
3# Author: Leonardo da Rosa Eugênio <lelgenio@disroot.org>
4
5set -l commands \
6    status up down once s u d o pause cont hup \
7    alarm interrupt quit 1 2 term kill exit p c h \
8    a i q 1 2 t k e start stop reload restart \
9    shutdown force-stop force-reload force-restart force-shutdown \
10    try-restart check
11
12function __fish_complete_sv_list_services
13    set -l svdir (path filter -d -- $SVDIR  \
14        /run/runit/runsvdir/current \
15        /run/runit/service \
16        /etc/services \
17        /services)
18    set -q svdir[1]; or return
19    set -l services (path basename -- $svdir[1]/*)
20    set -l sv_status (sv status $services 2>/dev/null |
21        string replace -ar ';.*$' '')
22    and string replace -r "^(\w+: )(.*?):" '$2\t$1' $sv_status
23    or printf "%s\n" $services
24end
25
26complete -f -c sv -a "(__fish_complete_sv_list_services)" -n "__fish_seen_subcommand_from $commands"
27
28complete -fc sv -s v -d "Report status for up, down, term, once, cont, and exit"
29complete -fc sv -s w -d "Override the default timeout to report status"
30
31set -l no_comm "not __fish_seen_subcommand_from $commands"
32
33complete -kfc sv -n $no_comm -a check -d "Check if the service is in it's requested state"
34complete -kfc sv -n $no_comm -a try-restart -d "Run term, cont, and  up, report status"
35complete -kfc sv -n $no_comm -a force-shutdown -d "Run exit, report status or kill on timeout"
36complete -kfc sv -n $no_comm -a force-restart -d "Run term, cont and up, report status"
37complete -kfc sv -n $no_comm -a force-reload -d "Run term and  cont, report status"
38complete -kfc sv -n $no_comm -a force-stop -d "Run down, report status or kill on timeout"
39complete -kfc sv -n $no_comm -a shutdown -d "Run exit, report status"
40complete -kfc sv -n $no_comm -a restart -d "Run term, cont, and  up, report status using ./check"
41complete -kfc sv -n $no_comm -a reload -d "Run hup, report status"
42complete -kfc sv -n $no_comm -a stop -d "Run down, report status"
43complete -kfc sv -n $no_comm -a start -d "Run up, report status"
44
45complete -kfc sv -n $no_comm -a e -d "Alias for exit"
46complete -kfc sv -n $no_comm -a k -d "Alias for kill"
47complete -kfc sv -n $no_comm -a t -d "Alias for term"
48complete -kfc sv -n $no_comm -a 2 -d "Alias for 2"
49complete -kfc sv -n $no_comm -a 1 -d "Alias for 1"
50complete -kfc sv -n $no_comm -a q -d "Alias for quit"
51complete -kfc sv -n $no_comm -a i -d "Alias for interrupt"
52complete -kfc sv -n $no_comm -a a -d "Alias for alarm"
53complete -kfc sv -n $no_comm -a h -d "Alias for hup"
54complete -kfc sv -n $no_comm -a c -d "Alias for cont"
55complete -kfc sv -n $no_comm -a p -d "Alias for pause"
56complete -kfc sv -n $no_comm -a exit -d "Send TERM, and CONT, report status"
57complete -kfc sv -n $no_comm -a kill -d "Send SIGKILL"
58complete -kfc sv -n $no_comm -a term -d "Send SIGTERM"
59complete -kfc sv -n $no_comm -a 2 -d "Send SIGUSR2"
60complete -kfc sv -n $no_comm -a 1 -d "Send SIGUSR1"
61complete -kfc sv -n $no_comm -a quit -d "Send SIGQUIT"
62complete -kfc sv -n $no_comm -a interrupt -d "Send SIGINT"
63complete -kfc sv -n $no_comm -a alarm -d "Send SIGALRM"
64complete -kfc sv -n $no_comm -a hup -d "Send SIGHUP"
65complete -kfc sv -n $no_comm -a cont -d "Send SIGCONT"
66complete -kfc sv -n $no_comm -a pause -d "Send SIGSTOP"
67
68complete -kfc sv -n $no_comm -a o -d "Alias for once"
69complete -kfc sv -n $no_comm -a d -d "Alias for down"
70complete -kfc sv -n $no_comm -a u -d "Alias for up"
71complete -kfc sv -n $no_comm -a s -d "Alias for status"
72complete -kfc sv -n $no_comm -a once -d "Start service, but don't restart it"
73complete -kfc sv -n $no_comm -a down -d "Send it the TERM signal"
74complete -kfc sv -n $no_comm -a up -d "Start a service"
75complete -kfc sv -n $no_comm -a status -d "Report the current status of the service"