From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_KAM_HTML_FONT_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26387 invoked from network); 19 Oct 2020 10:25:00 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Oct 2020 10:25:00 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1603103100; b=X6SPVhaNHVFM2AajfweuxaT10lPU+aAguHJvJ0dN5Ygbm/lkuTAYi7ri/1C1nurrqbe05CK/xZ DBpcMgZoH+VRBsYtg52NPn6qczboU1U1VMZRwClGihpbwtTkqwwUjWKdKu1g8riUh1ZVlUT0eZ 0Si7OIodAJxer3g7ibzzzMFrhgJBoZCu6x1EqsVG3n8fBhARPeGcjeDoLP4ZaDRS6zuCRxRD44 FiqtzPgo8aTNI1Z9TjNSAHMdiL606Dqv6sqWtmZ5ck8hxIxFHtxUm5vHyBCM7KYyRwVC9lYrSy p+GOGkHk6mBVM8hoU5Hl+f4FIwG3p0aUy7aBMaWEI+Mgvg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f41.google.com) smtp.remote-ip=209.85.210.41; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1603103100; bh=t+XCS4aUZ5qty0X8RjsgMvuckimA/mlBiEAXQhQ3e2I=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ZoavC+zSDFXsgbsogVt7J0yyP9INposfHJPWtQc0JGrl3SYpx9gTOoR1SF6Ct+toOoJ6VAtKSY /ydoC3Icl2fS4XRIPqzcqc2sb6kf3jBpC19BWNtM1GPTJu/9tC6JU/wbOy8u2oTXRSjvx3pZ7V kZgvj8o2Hg6+ev5Cqnyvn1G8qOOPp1CBcutTWpRf0+k+BM/TE91pcDKaCyONadZVsFbiraBmnP uT7tKTMvdPTrNbnlBzb+KLL4w4pYo/ieiH7L37ztpJh1EeoApWzsBDIS5gwn798asBiGOv4reJ p/BzVGOdtji+VOT7kMaqyUkfObtxDYXf+1aKwns3FUD8mA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=F3QlADRYWnodmCT30WrZVQYvcS33mwlvCQYH3gm3Qw0=; b=MWQT/C3ubuByzjwFnmp2LaxTz5 uPCcTsww+P5JGPHCg+3wJlj02Kz6Pp+Yp7fW91jref2yut3HpvSMR65sKTJY93Ap5MW8MHrlRspWf js7sTxaQuEu67rsyTC1f5qdxHjZZzD729BUgRqAtIeDBINQk34e43LwJfM4MYiFS0OiroyPKfQHuB 63AYwpfaqkLubdVaFERqIqABuNgxGKti8xtuahFtqm6SJdNPOeLhICeffd163MeaS7kizOEWofgsA j3FOrI6/0n9mdaoSmur+qoDCJYOjsLOwfOaNOojCSPrcBvAzI2v6mX4ll02MATA1dQRT6VVZUzCdK hbMLbu5Q==; Received: from authenticated user by zero.zsh.org with local id 1kUSLY-0002pH-C5; Mon, 19 Oct 2020 10:24:56 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f41.google.com) smtp.remote-ip=209.85.210.41; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ot1-f41.google.com ([209.85.210.41]:39554) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kUSL1-0002Rv-N0; Mon, 19 Oct 2020 10:24:25 +0000 Received: by mail-ot1-f41.google.com with SMTP id f10so9970878otb.6 for ; Mon, 19 Oct 2020 03:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F3QlADRYWnodmCT30WrZVQYvcS33mwlvCQYH3gm3Qw0=; b=qiraKvliOqh8GHdxBqz8h7bOLY31yD/EjJIgHJW371Udpymp1oBZMfxM8eHRVAla2m s0rFUAXcoe57MzvSdLoAa/7XM1UvMNscu3jm7OBTirPLCJdM6gog0UNAwWBf+Bwdpcwy POt8fSpztmNjOFrAOFe8UERskXQU6x0vLl0R1dWmEToghfhaogXcrIpGomvI4sCmLjcV 5Faht1azc50ikWAYDRpdLAJeLKMT4ju0LEfucdCYG019WbIiyrdss7+hk4WhTmi4Udgf /hywnUSckHMNTowLSqFAsqXRF1Y+j7MgUI1DioPP12prgvrEDAQOF4l1O3eHcedYc5ya fdmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F3QlADRYWnodmCT30WrZVQYvcS33mwlvCQYH3gm3Qw0=; b=tz7l+69YWhYpLkPfpVsCyC7OcU7ubiPOtR0fZkT6teRE0fLvRPwuRSkd1GKCvnOxhO c2XMNyHaRBzLARIBIuc/pxzV4VV0EixmupI4o/h/WFs6CWy1MdnwhfajuQyjleYTSMX+ /H9EvasDyPMKiUr2FfjtsYiXbWrUuvuXw90OZ2PrGAW2hFdZARtXMZl2VNeAVZvB4IFT teOhaAIk2/v+fYe8bIw6BhCkzK2VFx4K/VwEM/V02fdXXnFpJ4d7ykrOCFceOeMv22aG TGqB6dj/A6mMervuOb5d1OXedEV6H6duJXLK3mA9jw7IF07/Ej0sluU24Q6hJaWYuvOt eZJw== X-Gm-Message-State: AOAM531wEhYS1ayPDn6qiL1uGM1KY3DxIoEMpIK3MI8pEeE6neBjcObn 7Gs106WDV4eHmBsuPZ4j4rORJGcGZorWW0q/kBw= X-Google-Smtp-Source: ABdhPJzQT8KX7anhVnHUzAl1vBTq3WHPV6DQPUN75KGu1X9inogsiz13U5E/1zwTTjFytYN4qld/oZE1vS6wb2pugqs= X-Received: by 2002:a9d:7387:: with SMTP id j7mr11632860otk.18.1603103062455; Mon, 19 Oct 2020 03:24:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ahmad Ismail Date: Mon, 19 Oct 2020 16:24:11 +0600 Message-ID: Subject: Re: show completion description in single line To: Bart Schaefer Cc: Zsh Users Content-Type: multipart/alternative; boundary="0000000000009378f605b203848a" X-Seq: 26115 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --0000000000009378f605b203848a Content-Type: text/plain; charset="UTF-8" Hi Brat Schaefer, I can not express my gratitude with words. Thank you very much for showing us how it is done. I have modified the __git_extract_aliases in this case. solarizedalias came up with this solution ( https://www.reddit.com/r/zsh/comments/jdlavm/show_completion_description_in_single_line/g9b1lrk?utm_source=share&utm_medium=web2x&context=3). So, the resulting function is: (( $+functions[__git_extract_aliases] )) || __git_extract_aliases () { local -a tmp match mbegin mend tmp=(${${(0)"$(_call_program aliases "git config -z --get-regexp '^alias.'")"}#alias.}) if (( ${#tmp} > 0 )); then aliases=(${^tmp/$'\n'/:alias for \'}\') aliases=( ${(@)aliases//(#b)alias for \'(*)\'/alias for "'${match[1]//$'\n'/ }'"} ) else aliases=() fi } *Best Regards,Ahmad Ismail* On Mon, Oct 19, 2020 at 3:59 AM Bart Schaefer wrote: > On Sun, Oct 18, 2020 at 11:28 AM Ahmad Ismail wrote: > >> [...] multiline descriptions are draining my cognitive resources. Is >> there any way I can trim the description to single line. >> __git_extract_aliases >> >> However, I am not sure how to do it actually. Being said that, a zstyle >> solution will be much better for me. >> > > In the interests of "teach a man to fish" ... > > If you look at the source of __git_extract_aliases you will see that it > does this: > > tmp=(${${(0)"$(_call_program aliases "git config -z --get-regexp > '^alias.'")"}#alias.}) > > What you are seeing in the descriptions is thus the output from that "git > config" command. Your goal is to replace that with something that produces > less verbose results. > > You've already figured out that _call_program looks up the "command" > style, so you need to find the right context to pass. This is where ^X? > (the _complete_help binding) comes in handy. If you type ^X? (ctrl-x > questionmark) instead of tab, the completion system will dump a file in > /tmp with the full set of instructions that were executed in order to > generate the completion matches. You can then look through that file for > the _call_program run and find the context it used. > > (This is what I did to find "tree-files" in the other thread, except in > that case the $(_call_program ...) had stderr directed to /dev/null, so I > had to first remove that redirect.) > > As a shortcut ... you can see from the _call_program arguments that the > tag is "aliases", so you can construct a wildcard match: > > zstyle ':completion::complete:git*:*:aliases' command '...' > > Replace "..." with whatever variation of "git config" you need to produce > your desired abbreviated results. If the wildcards unexpectedly match > something you didn't intend, then you can dig deeper to find a more > specific context. > > Note I didn't test the above in any way, so details may need adjustment. > --0000000000009378f605b203848a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Brat Schaefer,

I can not = express my gratitude with words. Thank you very=C2=A0much for showing us ho= w it is done.

I have modified the __git_extract_al= iases in this case. solarizedalias came up with this solution (https://www.reddit.com/r/zsh/comments/jdlavm/show_completion_descript= ion_in_single_line/g9b1lrk?utm_source=3Dshare&utm_medium=3Dweb2x&co= ntext=3D3).

So, the resulting function is= :

(( $+functions[__git_extract_aliases] )) ||
_= _git_extract_aliases () {
=C2=A0 =C2=A0 local -a tmp match mbegin mend=C2=A0 =C2=A0 tmp=3D(${${(0)"$(_call_program aliases "git confi= g -z --get-regexp '^alias.'")"}#alias.})
=C2=A0 =C2=A0= if (( ${#tmp} > 0 )); then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 aliases=3D(${= ^tmp/$'\n'/:alias for \'}\')
=C2=A0 =C2=A0 =C2=A0 =C2=A0= aliases=3D( ${(@)aliases//(#b)alias for \'(*)\'/alias for "&#= 39;${match[1]//$'\n'/ }'"} )
=C2=A0 =C2=A0 else
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 aliases=3D()
=C2=A0 =C2=A0 fi
}

Best= Regards,

Ahmad Ismail



=
On Mon, Oc= t 19, 2020 at 3:59 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
On Sun= , Oct 18, 2020 at 11:28 AM Ahmad Ismail <ismail783@gmail.com> wrote:

[...]=C2=A0 multiline descriptions are draining my cognitive resour= ces. Is there any way I can trim the description to single line.

_= _git_extract_aliases

However, I am not sure how to do it actually.= Being said that, a zstyle solution will be much better for me.


In the interests of "teach = a man to fish" ...

If you look at the source = of __git_extract_aliases you will see that it does this:

tmp=3D(${${(0)"$(_call_program aliases "git config -z --ge= t-regexp '^alias.'")"}#alias.})

= What you are seeing in the descriptions is thus the output from that "= git config" command.=C2=A0 Your goal is to replace that with something= that produces less verbose results.

You'v= e already figured out that _call_program looks up the "command" s= tyle, so you need to find the right context to pass.=C2=A0 This is where ^X= ? (the _complete_help binding) comes in handy.=C2=A0 If you type ^X? (ctrl-= x questionmark) instead of tab, the completion system will dump a file in /= tmp with the full set of instructions that were executed in order to genera= te the completion matches.=C2=A0 You can then look through that file for th= e _call_program run and find the context it used.

= (This is what I did to find "tree-files" in the other thread, exc= ept in that case the $(_call_program ...) had stderr directed to /dev/null,= so I had to first remove that redirect.)

As a sho= rtcut ... you can see from the _call_program arguments that the tag is &quo= t;aliases", so you can construct a wildcard match:

zstyle ':completion::complete:git*:*:aliases' command '..= .'

Replace "..." with whatever varia= tion of "git config" you need to produce your desired abbreviated= results.=C2=A0 If the wildcards unexpectedly match something you didn'= t intend, then you can dig deeper to find a more specific context.

<= /div>
Note I didn't test the above in any way, so details may need = adjustment.
--0000000000009378f605b203848a--