* Context-sensitive completion args?
@ 2005-09-15 1:59 Lusk, Andrew
2005-09-15 3:02 ` Andrey Borzenkov
0 siblings, 1 reply; 2+ messages in thread
From: Lusk, Andrew @ 2005-09-15 1:59 UTC (permalink / raw)
To: zsh-users
I'd like to be able to complete one argument, with access to the completed value of another argument. Like so:
foocmd --arg1=a --arg2=
and in the completion code for arg2, have access to the value of arg1 (a). Is this possible?
Thanks,
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Context-sensitive completion args?
2005-09-15 1:59 Context-sensitive completion args? Lusk, Andrew
@ 2005-09-15 3:02 ` Andrey Borzenkov
0 siblings, 0 replies; 2+ messages in thread
From: Andrey Borzenkov @ 2005-09-15 3:02 UTC (permalink / raw)
To: zsh-users; +Cc: Lusk, Andrew
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
On Thursday 15 September 2005 05:59, Lusk, Andrew wrote:
> I'd like to be able to complete one argument, with access to the completed
> value of another argument. Like so:
>
> foocmd --arg1=a --arg2=
>
> and in the completion code for arg2, have access to the value of arg1 (a).
> Is this possible?
>
Yes, use _arguments function. It will parse the whole line and store existing
arguments/values in hash opt_args. Something like
_arguments \
"--arg1:arg1 description:(a b c)"\
"--arg2:arg2 decsription:_foocmd_arg2"
function _foocmd_arg2 () {
if [[ ${+opt_args[--foo2]} ]]; then
local arg1=$opt_args[--arg1]
... do something with arg1
fi
}
if empty value is the same no value at all you may just skip check for key
existence.
HTH
-andrey
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-15 3:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-15 1:59 Context-sensitive completion args? Lusk, Andrew
2005-09-15 3:02 ` Andrey Borzenkov
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).