commit 3adf33d1adfbc501a4fc32ceda1acf25b190b934 parent fc2f8674d726df289e650b79189c4221ff66c8a5 Author: Érico Rolim <erico.erc@gmail.com> Date: Wed, 26 Aug 2020 23:36:34 -0300 completions: import completions from void-packages Diffstat:
A | completions/sv.bash | | | 26 | ++++++++++++++++++++++++++ |
A | completions/sv.zsh | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/completions/sv.bash b/completions/sv.bash @@ -0,0 +1,26 @@ +# bash completion for runit sv(1) + +_sv() +{ + local cur prev words cword commands + _init_completion || return + + commands='up down status once pause cont hup alarm interrupt 1 2 term kill exit start stop restart shutdown force-stop force-reload force-restart force-shutdown' + + case $prev in + -w) + return + ;; + -* | sv) + COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) + return + ;; + *) + COMPREPLY=( /var/service/* ) + COMPREPLY=( ${COMPREPLY[@]##*/} ) + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- ${cur}) ) + return + ;; + esac +} +complete -F _sv sv diff --git a/completions/sv.zsh b/completions/sv.zsh @@ -0,0 +1,44 @@ +#compdef sv + +# completion for runit sv(1) +# Leah Neukirchen <leah@vuxu.org> +# 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