From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 54d710e9 for ; Mon, 21 Oct 2019 06:58:41 +0000 (UTC) Received: (qmail 3271 invoked by alias); 21 Oct 2019 06:58:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24370 Received: (qmail 11979 invoked by uid 1010); 21 Oct 2019 06:58:32 -0000 X-Qmail-Scanner-Diagnostics: from st13p97im-ztdg18301101.me.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25608. spamassassin: 3.4.2. Clear:RC:0(17.41.193.160):SA:0(-2.7/5.0):. Processed in 1.865962 secs); 21 Oct 2019 06:58:32 -0000 X-Envelope-From: c.nebel@mac.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at mac.com designates 17.41.193.160 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1571641075; bh=2F8XNJfsXgNS80tpF2pKJx5qlSzgHUy6XkPrLKKxYdg=; h=From:Content-Type:Subject:Message-Id:Date:To; b=LfIAzH2zT9Wz2RFOkyZH94jqzF0hW8XUGzz1dXC+V039x71YERwJRC4kdIiRnVJxx HJOwoXmkIMEkQAYQMchHkQtMon5ZBKx7R2FXdQIyM8BMoGGcvXH36dxskSa16yLbX3 nszh1NmDw3kQY1aOWV1hWSZn2vRjYP1HbPT1g8xa10mJESBQm1gBx+5THjlz7ZJ/m5 xMhX96eqzFhIkdv6veqyLBBRbUe7pHE075JlOo9VBpYQFfl4umsk6gplWay6WlaQNj WlVo6SbDrEGT8ALc6s+yAZetKj0v6ovxJwT0OecVnu5xx/ibVwcivxadWgKuQ7oswD ELeChNt7hjuDg== From: Chris Nebel Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Grouping and ordering completions with zshcompsys? Message-Id: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com> Date: Sun, 20 Oct 2019 23:57:53 -0700 To: zsh-users@zsh.org X-Mailer: Apple Mail (2.3445.104.11) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-21_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=953 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1910210063 zsh-users=E2=80=94 I=E2=80=99ve been fiddling with a zsh completion function for = darwinup(1), partly as a learning exercise, partly because I wanted one. = (I=E2=80=99m aware of = , but it=E2=80=99s = not as smart as I wanted, and learning exercise.) For the most part = I=E2=80=99ve got it working, but I=E2=80=99m struggling with grouping = and ordering. For background, darwinup(1) manages installed =E2=80=9Carchives=E2=80=9D = =E2=80=94 it=E2=80=99s basically a simple package manager =E2=80=94 and = if you ask for a list of what=E2=80=99s installed, you get something = like this: Serial UUID Date Build Name =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D 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 =E2=80=9Cserial=E2=80=9D, UUID, or name, so = I=E2=80=99d like to complete the serial number or name. Additionally, = there are four meta-names: =E2=80=9Call=E2=80=9D, =E2=80=9Cnewest=E2=80=9D= , =E2=80=9Coldest=E2=80=9D, and =E2=80=9Csuperseded=E2=80=9D, which = should also be completable. Merely providing all those as completion options is easy =E2=80=94 what = I haven=E2=80=99t 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 =20 > 4 bbq.tgz -- installed on 18F205 at Oct 20 00:18 > 42 foobar.tgz -- installed on 18F205 at Oct 20 00:19 >=20 > 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=E2=80=99d like the = exclusion behavior that =E2=80=9C_arguments=E2=80=9D has, so it won=E2=80=99= t complete the same archive more than once, and if the user already = typed =E2=80=9Call=E2=80=9D it won=E2=80=99t complete anything more. = The closest I=E2=80=99ve 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 =20 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=E2=80=99t have = descriptions. I got the regular archives to sort in numeric order by = ordering them myself and using =E2=80=9C_describe -V=E2=80=9D, but then = I lose the exclusions, and everything I=E2=80=99ve tried so far puts the = serial numbers *after* the names. It=E2=80=99s not terrible, but I=E2=80=99= m at a loss for how to do better. An example would help, but I = haven=E2=80=99t yet found an existing command that does anything like = this. Any pointers? =E2=80=94Chris N.=