From: Andrey Borzenkov <arvidjaar@newmail.ru>
To: zsh-users@sunsite.dk
Cc: "Lusk, Andrew" <andrewlu@amazon.com>
Subject: Re: Context-sensitive completion args?
Date: Thu, 15 Sep 2005 07:02:41 +0400 [thread overview]
Message-ID: <200509150702.42369.arvidjaar@newmail.ru> (raw)
In-Reply-To: <1D7B5D8FB046374991CF568E259E6D5F04E860E0@ex-mail-sea-02.ant.amazon.com>
[-- 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 --]
prev parent reply other threads:[~2005-09-15 3:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-15 1:59 Lusk, Andrew
2005-09-15 3:02 ` Andrey Borzenkov [this message]
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=200509150702.42369.arvidjaar@newmail.ru \
--to=arvidjaar@newmail.ru \
--cc=andrewlu@amazon.com \
--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).