Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [Feature request] Bash-completion for runit sv (Read 1041 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

[Feature request] Bash-completion for runit sv

sv on Artix has no completion script. While you can always run ls /run/runit/service and use the single-letter shortcuts (or even RSM), having a completion script would be a nice addition to the official runit/bash-completion package.

So far, I'm using Void's completion script (installed as an extra package, ran through with sed -i s@/var/@/run/runit/@g to be compatible with Artix):
https://raw.githubusercontent.com/void-linux/runit/master/completions/sv.bash


Re: [Feature request] Bash-completion for runit sv

Reply #2
hey, thanks, exactly what i was looking for !
This page came up in first on startpage :D

the aur package does not exist anymore, but writing it to /usr/share/bash-completion/completions/sv does the trick
and to be perfect, change the path /var/service/ to /run/runit/service/ to be able to autocomplete the name of the service
here is the final version to use:

Code: [Select]
# 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=( /run/runit/service/* )
            COMPREPLY=( ${COMPREPLY[@]##*/} )
            COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- ${cur}) )
            return
            ;;
    esac
}
complete -F _sv sv


having the autocompletion is always nice :), so, shouldn't it be included in the runit installation ?

Re: [Feature request] Bash-completion for runit sv

Reply #3
Just added it, avoid necroposting please.

Re: [Feature request] Bash-completion for runit sv

Reply #4
great, thanks @qontinuum :)
(sorry for necro posting, i thought it was better to answer here than an other post saying the same thing)