Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion with descriptions
- X-seq: zsh-users 10096
- From: Andy Spiegl <zsh.Andy@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: completion with descriptions
- Date: Mon, 27 Mar 2006 18:30:58 +0200
- In-reply-to: <EXCHANGE03k6gYKeiMH000034a5@xxxxxxxxxxxxxxxxxx>
- Kinfo: virscan ok
- Kinfo: !spam auth
- Kreccount: 1
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060327132750.GB27668@xxxxxxxxx> <EXCHANGE03k6gYKeiMH000034a5@xxxxxxxxxxxxxxxxxx>
Thank you for the example, Peter!
I tried to dig in deeply into writing completion functions now. :-)
I took _aptitude as a template and came up with the following (see below)
which works as wanted except for the fact that zsh inserts the _whole_ line
(command + description) instead of just the command. *sigh*
Like so:
 condor:~>gigaset del\ \ \ \ \ \ \ \ \ --\ Aufnahme\ löschen
 gigaset commands
 del         -- Aufnahme löschen                                    
 demux       -- Aufnahme mit projectX demultiplexen                 
 details     -- Details anzeigen                                    
 dir         -- Liste der Aufnahmen                                 
 dump        -- Details anzeigen                                    
 mux         -- Video+Audio(s) wieder zu einer MPG-Datei multiplexen
 title       -- Kurzübersicht (Aufnahme-Titel in nur 1 Zeile)       
Can someone see where my error is, please?
Here are the relevant parts of the function:
 (the whole thing is also here: http://andy.spiegl.de/software/_gigaset)
[...]
_arguments -S \
[...]
   '--commands[Liste aller Kommandos]' \
   '1: :->cmds' \
   '*: :->args'
case $state in
  cmds)
    cmds=( ${${(M)${(f)"$(gigaset --commands 2>/dev/null)"}:#* -- *}/(#b) (*[^ ]) #-- (*)/$match[1]:$match[2]:l})
    _describe -t commands "gigaset commands" cmds && ret=0
  ;;
  args)
[...]
  ;;
esac
Thx,
 Andy.
-- 
 For every problem there is one solution which is simple, neat, and wrong. 
   -- Henry L. Mencken 
Messages sorted by:
Reverse Date,
Date,
Thread,
Author