Artix Linux Forum

Artix Linux => Software development => Topic started by: capezotte on 19 May 2021, 12:57:55

Title: [Feature request] Bash-completion for runit sv
Post by: capezotte on 19 May 2021, 12:57:55
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
Title: Re: [Feature request] Bash-completion for runit sv
Post by: capezotte on 19 July 2021, 18:37:11
In case anyone is interested, I got around and uploaded this package to the AUR:

https://aur.archlinux.org/packages/runit-completion/
Title: Re: [Feature request] Bash-completion for runit sv
Post by: Dju on 23 May 2022, 02:22:26
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 ?
Title: Re: [Feature request] Bash-completion for runit sv
Post by: qontinuum on 24 May 2022, 19:33:04
Just added it, avoid necroposting please.
Title: Re: [Feature request] Bash-completion for runit sv
Post by: Dju on 24 May 2022, 19:54:16
great, thanks @qontinuum :)
(sorry for necro posting, i thought it was better to answer here than an other post saying the same thing)
Title: Re: [Feature request] Bash-completion for runit sv
Post by: cat herders of linux on 24 May 2022, 23:04:50
Just added it, avoid necroposting please.

Thanks!  You rock!