Zsh Mailing List Archive
Messages sorted by:
Re: Implementing a menu (list) in a zsh script (as in command line)
- X-seq: zsh-users 17515
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: rahul <rahul2012@xxxxxxxxx>
- Subject: Re: Implementing a menu (list) in a zsh script (as in command line)
- Date: Mon, 31 Dec 2012 12:00:35 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1356951635; bh=piKIWwoPZotMoKa4AK73xmAt9Cpuv+mrSn4kNzE/mbk=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:cc:In-reply-to:From:References:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=pNW3HgIAbiJg24EE7BDHwsv+BPgdwtSd+oYfbcxD1PZRr6mKTl6VBBASTGPy3FnV2+EiOfl4htpQNhoV8d1NTitUZBzkvOT2ff3N6HnBKjIX90FN4dNNfPj5lVsaMA873KMmQoow7/vWGozVYrJuVSDBLh48FrmAXIpK/rCytTI=
- In-reply-to: <CACQNQ9P7WJCvuPCzJfxKsf=qZsXiNxsv5hxA-xG8WTJQDugMzw@mail.gmail.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CACQNQ9P7WJCvuPCzJfxKsf=qZsXiNxsv5hxA-xG8WTJQDugMzw@mail.gmail.com>
> I am writing an application in zsh. I typically use read -k or vared for
> getting user input. However, I'd like the user to get a menu as he types or
> tabs, just as it happens on the zsh command line. I'd like him to be able
> to navigate the menu just as on the command line.
With vared, you should be able to configure a function that does
completion for your script by declaring it with zle -C:
zle -C complete-word complete-word _complete
bindkey '^I' complete-word
Looking at a script I have that does this, my _complete function starts
[[ "$compstate[insert]" = tab* ]] &&
I think this ensures that it does completion rather than inserting a tab
character in some cases.
You may need other tweaking, much of which may involve copying from your
.zshrc to, for example, setup menu completion as you like it loading the
complist module and so on.
The completion functions may also look a bit different to normal
completion functions if you do things like descriptions manually, e.g.
compadd -X '%Bnames%b'
Messages sorted by: