zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Ahmad Ismail <ismail783@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: show completion description in single line
Date: Sun, 18 Oct 2020 14:59:45 -0700	[thread overview]
Message-ID: <CAH+w=7b1QQzUZY0zG=dvZw_QXo=KzPZvOcibTXNcpzYNCEPV2w@mail.gmail.com> (raw)
In-Reply-To: <CAHAhJwK5x+Wt37ADeG1DsBhD7VWg=DyJop_RA+JV=SmpJd0w2A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]

On Sun, Oct 18, 2020 at 11:28 AM Ahmad Ismail <ismail783@gmail.com> 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.

[-- Attachment #2: Type: text/html, Size: 2638 bytes --]

  reply	other threads:[~2020-10-18 22:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-18 18:28 Ahmad Ismail
2020-10-18 21:59 ` Bart Schaefer [this message]
2020-10-19 10:24   ` Ahmad Ismail

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7b1QQzUZY0zG=dvZw_QXo=KzPZvOcibTXNcpzYNCEPV2w@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=ismail783@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).