Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: dynamic file completion
- X-seq: zsh-users 10057
- From: Andy Spiegl <zsh.Andy@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: dynamic file completion
- Date: Tue, 21 Mar 2006 17:35:52 +0100
- In-reply-to: <EXCHANGE03ekWo76Uai0000103c@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: <20060317170315.GA19760@xxxxxxxxx> <EXCHANGE03ekWo76Uai0000103c@xxxxxxxxxxxxxxxxxx>
Peter Stephenson wrote:
> You need the -W argument to _files; I'd suggest using "_path_files -W
> <dir>", since going directly to _path_files removes some smart behaviour
> in _files you don't want in this case.
Great, that works! I don't even need the extra file _cridfiles anymore!
> So you need to use your specific directory, but override it if there's a
> --dir. You'll need to check if there's a --dir on the command line
> already and grab it's argument. You need something like:
Wonderful, I always loved zsh! :-)
But _path_files seems to have a problem with paths with ~ in it.
This works:
gigaset --dir /home/spiegl/movies/gigaset/PVR ls <TAB>
but this doesn't:
gigaset --dir ~/movies/gigaset/PVR ls <TAB>
Can that be done too?
Ah, neither does this work:
gigaset --dir $HOME/movies/gigaset/PVR ls <TAB>
Thanks,
Andy.
Okay, here's what I wrote so far:
-------------------------------------------------
#compdef gigaset
local dir=${words[(r)--dir=*]##--dir=}
if [[ -z $dir ]]; then
integer dirind=${words[(i)--dir]}
if (( dirind )); then
dir=$words[dirind+1]
fi
fi
if [[ -z $dir ]]; then
dir="/data/movies/gigaset/PVR/"
fi
_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:_path_files -/' \
'--exportdir=[Verzeichnis für den TS-Export der Aufnahmen]:exportdir:_path_files -/' \
'--cutdir=[Verzeichnis mit den fertig geschnittenen (noch nicht gemuxten) Filmen]:cutdir:_path_files -/' \
'--mpgdir=[Verzeichnis mit den fertig geschnittenen und gemuxten MPG-Filmen]:mpgdir:_path_files -/' \
'(--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:_path_files -W $dir -g "*.crid"'
-------------------------------------------------
--
Your mouse has moved. Windows must be restarted for the change
to take effect. Reboot now?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author