Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Grouping and ordering completions with zshcompsys?
- X-seq: zsh-users 24371
- From: Chris Nebel <c.nebel@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Grouping and ordering completions with zshcompsys?
- Date: Mon, 21 Oct 2019 00:02:53 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1571641374; bh=tkTsq+kiFecSC2N50Ahj9zOohUJkc8qTTdQDaL2j5H8=; h=From:Content-Type:Subject:Date:To:Message-Id; b=jmvRQ5KptGCbnleJltx0itC7IDfqShFPBGSzbAmaKFsb+KUMidkWiwkbXvYnmVv4Z lyEt3F/HUGV1SfJl5VL+BvjVpibQh+f3SNc8z8D7og/e6j2Pail2HPUJ44pXWG++oN ISCWzKRxZ5JxVZ7sLI3fgTSXyffXT5gIEFJuWMMWVJtwykNsUJfbZeNTlAgK/MekGl xvALFbiyzdjjx+uzoLpYayAIrPkBDInmR/AjBFVdfv96ePG/VesZFlruInfSybA8LX x3+mZmZQ+4+oz3unCKXbR0ul6CsVxvhi5GRt/em2ZcE9GUSYHmcGUAT2eDTBXTy4ds HMynssmgGk2zA==
- In-reply-to: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <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@xxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author