guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#45004] Bash completion for ‘herd’


From: Ludovic Courtès
Subject: [bug#45004] Bash completion for ‘herd’
Date: Fri, 02 Jun 2023 15:56:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi Oleg,

Oleg Pykhalov <go.wigust@gmail.com> skribis:

> You could take my, which probably should be improved before merging to
> Shepherd IMHO, e.g. avoid 'awk'.
>
> ~/.local/share/bash-completion/completions/herd
>
> _herd_complete_service(){
>     local command="${COMP_WORDS[1]}"
>     local services="$(sudo herd status | awk '/*/ || /^ +/ || /^ -/ { print 
> $NF }' | sort -u)"
>     COMPREPLY=($(compgen -W "$services" -- "${COMP_WORDS[$COMP_CWORD]}"))
> }
>
> _herd_is_command ()
> {
>     local word
>     local result="false"
>     for word in ${COMP_WORDS[*]}t
>     do
>       if [ "$word" = "$1" ]
>       then
>           result=true
>           break
>       fi
>     done
>     $result
> }
>
> _herd_complete()
> {
>     local word_count=${#COMP_WORDS[*]}
>     local word_at_point="${COMP_WORDS[$COMP_CWORD]}"
>     case $COMP_CWORD in
>         1)
>           if [ -z "$_herd_subcommands" ]
>           then
>               # Cache the list of subcommands to speed things up.
>               _herd_subcommands="enable disable start status stop"
>           fi
>             COMPREPLY=($(compgen -W "$_herd_subcommands" -- 
> "${COMP_WORDS[$COMP_CWORD]}"))
>             ;;
>         *)
>             case $COMP_CWORD in
>               2) _herd_complete_service;;
>           esac
>             ;;
>     esac
> }
>
> complete -F _herd_complete herd

Would you mind polishing a bit (as you see fit; perhaps use grep/sed
rather than Awk?) and submitting a patch for this?  I’d be happy to
apply it!

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]