zsh-users
 help / color / mirror / code / Atom feed
From: Eric Cook <llua@gmx.com>
To: zsh-users@zsh.org
Subject: Re: Completion of two items separated by a dash
Date: Thu, 28 Jun 2018 16:03:47 -0400	[thread overview]
Message-ID: <d448e5c3-2f8e-0950-ad39-9ce2eb932eeb@gmx.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2018-06-28 20:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28 19:40 Scott Frazer (scfrazer)
2018-06-28 20:03 ` Eric Cook [this message]
2018-06-29 15:54   ` Scott Frazer (scfrazer)

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=d448e5c3-2f8e-0950-ad39-9ce2eb932eeb@gmx.com \
    --to=llua@gmx.com \
    --cc=zsh-users@zsh.org \
    /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).