Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: completion with descriptions



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