zsh-users
 help / color / mirror / code / Atom feed
* dynamic file completion
@ 2006-03-17 17:03 Andy Spiegl
  2006-03-17 17:34 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Spiegl @ 2006-03-17 17:03 UTC (permalink / raw)
  To: zsh-users

Hi!

I just wrote my first completion function, yippieh. :-)

It basically works but I'd like to add the feature that the filenames to be
completed are from a specific directory (without the path) and that this
directory can be overriden with the cmdline parameter --dir (or --criddir).
So somehow the function has to dynamically change the list of possible
files, right?  I have no idea how to do that nicely.  Please help!

Here's the function:  (please ignore the German comments)
------------------------------------------------------------------
#compdef gigaset

_arguments \
   '(--help --usage)'{--help,--usage}'[Hilfestellung anzeigen]' \
   '--version[Programmversion anzeigen]' \
   '--manpage[komplette Manpage aufrufen]' \
   '--debug[Debugmodus aktivieren, mehrfach benutzbar]' \
   '(--dir --criddir)'{--dir=,--criddir=}'[Verzeichnis mit den Aufnahmen und crid-Dateien]:criddir:_directories' \
   '--exportdir=[Verzeichnis für den TS-Export der Aufnahmen]:exportdir:_directories' \
   '--cutdir=[Verzeichnis mit den fertig geschnittenen (noch nicht gemuxten) Filmen]:cutdir:_directories' \
   '--mpgdir=[Verzeichnis mit den fertig geschnittenen und gemuxten MPG-Filmen]:mpgdir:_directories' \
   '(--yes --ja)'{--yes,--ja}'[Keine Sicherheitsabfragen, immer ja antworten]' \
   '--nowarnings[Warnungen unterdrücken]' \
   '(--dontdel --nodel)'{--dontdel,--nodel}'[Temporäre Dateien nicht löschen]' \
   '(--force --overwrite)'{--force,--overwrite}'[vorhandene Dateien überschreiben]' \
   '(--nocolor --nc)'{--nocolor,--nc}'[monochrome Ausgabe]' \
   '(--alang --audiolang)'{--alang=,--audiolang=}'[Audio-Sprache einstellen, z.B. -alang deu,fra]:alang:(deu fra en spa it)' \
   '--search=[Beschränkung auf Aufnahmen mit dem Suchstring]:string:' \
   '--commands[Liste aller Kommandos]' \
   ':cmds: compadd ${${(f)"$(gigaset --commands)"}%%[[:space:]]##--*}' \
   '*:cridfiles:_cridfiles'
------------------------------------------------------------------

For the last line to work I had to write another file "_cridfiles":
(How can I include this definition in the first file?)

------------------------------------------------------------------
#compdef gigaset

local expl ext

_description files expl 'crid file for gigaset'
_files "$@" "$expl[@]" -g "*.(#i)crid"
------------------------------------------------------------------


Thanks a lot and have a nice weekend!,
 Andy.

-- 
 Linux - It is now safe to turn on your computer.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-21 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-17 17:03 dynamic file completion Andy Spiegl
2006-03-17 17:34 ` Peter Stephenson
2006-03-21 16:35   ` Andy Spiegl

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).