Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion of two items separated by a dash
- X-seq: zsh-users 23512
- From: Eric Cook <llua@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Completion of two items separated by a dash
- Date: Thu, 28 Jun 2018 16:03:47 -0400
- In-reply-to: <ph3dem$hod$1@blaine.gmane.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <ph3dem$hod$1@blaine.gmane.org>
On 06/28/2018 03:40 PM, Scott Frazer (scfrazer) wrote:
> I am trying to write a completion function for a command that takes two items separated by a dash, and the second item depends on the first. For example, suppose possible full completions were:
>
> foo-bar
> foo-baz
> abc-def
> abc-xyz
>
> Ideally, the completion function would first present options "foo" and "abc", then after the user chooses one it inserts the "-', and when you hit tab again it presents either "bar" and "baz" or "def" and "xyz".
>
> For this simple example I could just show all four, but in real life there are many first items and many second items and the list would be huge.
>
> I have written some simple completions before, but this has me stumped. Is there a way to do this?
>
> Thanks,
> Scott
>
_foo() {
local -a ary
ary=( foo-bar foo-baz abc-def abc-xyz )
_arguments '1:description:_multi_parts -- - ary'
}
compdef _foo foo
Messages sorted by:
Reverse Date,
Date,
Thread,
Author