From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oG+bIkH1eWQXngAASxT56A (envelope-from ) for ; Fri, 02 Jun 2023 15:57:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4H50IkH1eWTtHQAA9RJhRA (envelope-from ) for ; Fri, 02 Jun 2023 15:57:21 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 52FA928D3A for ; Fri, 2 Jun 2023 15:57:21 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q55H7-0006Ni-87; Fri, 02 Jun 2023 09:57:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q55H4-0006ND-Sb for guix-patches@gnu.org; Fri, 02 Jun 2023 09:57:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q55H4-0000N9-IY for guix-patches@gnu.org; Fri, 02 Jun 2023 09:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q55H4-0002Dz-F3 for guix-patches@gnu.org; Fri, 02 Jun 2023 09:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#45004] Bash completion for =?UTF-8?Q?=E2=80=98herd=E2=80=99?= Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 02 Jun 2023 13:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45004 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: 45004@debbugs.gnu.org, Jonathan Brielmaier Received: via spool by 45004-submit@debbugs.gnu.org id=B45004.16857141828505 (code B ref 45004); Fri, 02 Jun 2023 13:57:02 +0000 Received: (at 45004) by debbugs.gnu.org; 2 Jun 2023 13:56:22 +0000 Received: from localhost ([127.0.0.1]:40513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q55GP-0002D7-ME for submit@debbugs.gnu.org; Fri, 02 Jun 2023 09:56:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q55GN-0002D0-K4 for 45004@debbugs.gnu.org; Fri, 02 Jun 2023 09:56:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q55GI-00007Q-B8; Fri, 02 Jun 2023 09:56:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=P04Qs/qnaa5WB5J5tcs4JCsvDgQ+TDPHcHL6ThbrznY=; b=Eu3t94Oa6hHqhVjC0sfX 4C1pZB1MflAaOi3cq60t0ZpXKLENVBmbj+1sE9cVBO24bFnanDzwBjWvTO8/DRThsaEbl1V8pXmr4 AXB9Ni5lqLMMCVd33/8Z7kdnq/giMQzwnZmWE0fcQ8xOTFFpAFuC6EJfZtl3PgQMG45xSRek2+upL cBexUGFgoqEzZchj3yvzXxaHPI91AS/uHS2X2dwBkDEpMvqbWHB5PXyZqzb07udS9WN8jlb/DWYwO /9UFFZYCmVcmZs2IicVHxjuZGzjsWgHbu27mw28rx4Xwmx4cqt2dYziKyTb3T2P+glqONsIoGEasj OWLF2CCI42nkEQ==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q55GH-00023R-Tr; Fri, 02 Jun 2023 09:56:14 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20201202092106.22770-1-leo.prikler@student.tugraz.at> <87a6utqyku.fsf@gmail.com> Date: Fri, 02 Jun 2023 15:56:11 +0200 In-Reply-To: <87a6utqyku.fsf@gmail.com> (Oleg Pykhalov's message of "Fri, 04 Dec 2020 20:18:41 +0300") Message-ID: <87h6rq55ok.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685714241; a=rsa-sha256; cv=none; b=FIKe5XuTMqlozqbwtBQYzgUckCp3ZJ0kQqwoPXG4PcGIaB2tdKQO+nTkBLwRE+KnhgHHQS 3n2iL4yBHhl4il/6SPy4RKgbwSG4EH4xoE0qBZCAsnlGl4lt7c9CnUgWMfIkpk2kenPU5x 28Uwn4xdlfl6yTDG6bR9qqa/Y6gKqJJGxTQFsLKdtMvqigH8ODMZKMjGot0Gu58cDiTW21 jALv76kJWtecoICtsueM7FYxa8oPQ9CmbJ2qguV5TQVNlfgw7sFv9hR9YTXcm2tYahsAro jz673mvcTBHTKaQJI+0kBzIvqteKcCna3nBxH1A0p3FsybHQJsi0URdrOUPYZQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Eu3t94Oa; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685714241; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=P04Qs/qnaa5WB5J5tcs4JCsvDgQ+TDPHcHL6ThbrznY=; b=fkN0JJOegkvWctEAV6/GadwJNvBUt448iWtZRkohKBjgLxyjuSd7F9OC59CshCzzuaKWRy vsgU6djmClm83wpaI/33r9Gq8O2zt1ZFTO7j/MmUKsNwdlUy/3tULYiZJkZYzeOQZX8fvV vQgUINBxp1J4bzXUpMfcOt4YbjyX9yoKUDwIgEPpLiWDXaMjknaOt7FqI+fw7c4NF8A/6c KjEosZnPMDcJIwrzzkM9BzNTAz3LdMitKCGVOhFyLkul1KdVo42wO3PnW7aHO4yojxLRr6 SukdkX2i2S/cEnHkWAWhEBfHzRjQXAWcx+qqwPZEyFR2hRVTzt/VMtiMmCjr9w== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Eu3t94Oa; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -5.17 X-Spam-Score: -5.17 X-Migadu-Queue-Id: 52FA928D3A X-TUID: sbz8KKkA7gsO Hi Oleg, Oleg Pykhalov 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=3D"${COMP_WORDS[1]}" > local services=3D"$(sudo herd status | awk '/*/ || /^ +/ || /^ -/ { p= rint $NF }' | sort -u)" > COMPREPLY=3D($(compgen -W "$services" -- "${COMP_WORDS[$COMP_CWORD]}"= )) > } > > _herd_is_command () > { > local word > local result=3D"false" > for word in ${COMP_WORDS[*]}t > do > if [ "$word" =3D "$1" ] > then > result=3Dtrue > break > fi > done > $result > } > > _herd_complete() > { > local word_count=3D${#COMP_WORDS[*]} > local word_at_point=3D"${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=3D"enable disable start status stop" > fi > COMPREPLY=3D($(compgen -W "$_herd_subcommands" -- "${COMP_WOR= DS[$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=E2=80=99d be happy to apply it! Thanks, Ludo=E2=80=99.