From: Chris Nebel <c.nebel@mac.com>
To: zsh-users@zsh.org
Subject: Re: Grouping and ordering completions with zshcompsys?
Date: Mon, 21 Oct 2019 00:02:53 -0700 [thread overview]
Message-ID: <4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.com> (raw)
In-Reply-To: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com>
Related question: is there a way to get _files to only complete files that pass a test of some sort? Specifically, I want files that are in one of four (possibly compressed) archive formats. I can get a thumbs-up/thumbs-down decision using file(1), but I don’t see how to communicate that to _files.
> On Oct 20, 2019, at 11:57 PM, Chris Nebel <c.nebel@mac.com> wrote:
>
> zsh-users—
>
> I’ve been fiddling with a zsh completion function for darwinup(1), partly as a learning exercise, partly because I wanted one. (I’m aware of <https://github.com/tetsuok/darwinup-zsh-completion>, but it’s not as smart as I wanted, and learning exercise.) For the most part I’ve got it working, but I’m struggling with grouping and ordering.
>
> For background, darwinup(1) manages installed “archives” — it’s basically a simple package manager — and if you ask for a list of what’s installed, you get something like this:
>
> Serial UUID Date Build Name
> ====== ==================================== ============ ======= =================
> 1 6F5662BD-4D69-470E-B708-3D0F3706D0A6 Sep 20 00:16 18A396 omg.tgz
> 2 CB732989-ACB4-49B4-B49C-64F40EF2B17B Sep 22 00:16 17A42 zomg.tgz
> 4 C2AF0BF1-9FA3-4EE7-A402-32CDBCDA0F8C Sep 23 00:18 18F205 bbq.tgz
> 42 52FC4789-769C-4CD8-A39B-D1B6CC0B2009 Oct 01 12:34 18F205 foobar.tgz
>
> darwinup has various sub-commands which take archives as arguments, which can be specified by “serial”, UUID, or name, so I’d like to complete the serial number or name. Additionally, there are four meta-names: “all”, “newest”, “oldest”, and “superseded”, which should also be completable.
>
> Merely providing all those as completion options is easy — what I haven’t been able to do is get them listed the way I want, which is something like this:
>
>> archives
>> 1 omg.tgz -- installed on 18A396 at Oct 15 00:16
>> 2 zomg.tgz -- installed on 17A42 at Oct 19 00:16
>> 4 bbq.tgz -- installed on 18F205 at Oct 20 00:18
>> 42 foobar.tgz -- installed on 18F205 at Oct 20 00:19
>>
>> meta-archives
>> all -- all archives
>> newest -- most recently installed archive
>> oldest -- least recently installed archive
>> superseded -- all archives replaced by other archives
>
> Notice the two distinct groups with names, and the serial numbers appearing before the names. For bonus points, I’d like the exclusion behavior that “_arguments” has, so it won’t complete the same archive more than once, and if the user already typed “all” it won’t complete anything more. The closest I’ve managed to get this this:
>
> omg.tgz 1 -- installed on 18A396 at Oct 15 00:16
> zomg.tgz 2 -- installed on 17A42 at Oct 19 00:16
> bbq.tgz 4 -- installed on 18F205 at Oct 20 00:18
> foobar.tgz 42 -- installed on 18F205 at Oct 20 00:19
> all newest oldest superseded
>
> I can get force the meta-archive names to appear together at the end by not giving them descriptions, but then they don’t have descriptions. I got the regular archives to sort in numeric order by ordering them myself and using “_describe -V”, but then I lose the exclusions, and everything I’ve tried so far puts the serial numbers *after* the names. It’s not terrible, but I’m at a loss for how to do better. An example would help, but I haven’t yet found an existing command that does anything like this. Any pointers?
>
>
> —Chris N.
next prev parent reply other threads:[~2019-10-21 7:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 6:57 Chris Nebel
2019-10-21 7:02 ` Chris Nebel [this message]
2019-10-21 8:51 ` dana
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=4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.com \
--to=c.nebel@mac.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).