From: Andy Spiegl <zsh.Andy@spiegl.de>
To: zsh-users@sunsite.dk
Subject: dynamic file completion
Date: Fri, 17 Mar 2006 18:03:15 +0100 [thread overview]
Message-ID: <20060317170315.GA19760@spiegl.de> (raw)
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.
next reply other threads:[~2006-03-17 17:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-17 17:03 Andy Spiegl [this message]
2006-03-17 17:34 ` Peter Stephenson
2006-03-21 16:35 ` Andy Spiegl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060317170315.GA19760@spiegl.de \
--to=zsh.andy@spiegl.de \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).