From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3187 invoked by alias); 31 Dec 2012 11:07:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17515 Received: (qmail 6437 invoked from network); 31 Dec 2012 11:07:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_40,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.co.uk does not designate permitted sender hosts) 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= X-Yahoo-Newman-Id: 973313.63024.bm@smtp129.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: qu8E3VgVM1kIrk9VnyDP4DtYSkumas8zVemihpNbfCQdlmD SHJjGsZnLskOG.yusBFK0Mw90.NqP9kBLE9PsURIgMzIWdbeb6p7SeoUyHg3 gHw4hTrv5hjv5uidB0yr0oEEnYTIdvCmADOW_1epf4ajX.hqVAeejYmIJX5G C_ZT.yf1sKKf4wZIOVoYmgUcfhACi6yp3a7nySNcg4AXDPk2Gf2nin11h_nH Et11wUZfWUwR_qYQ3vDzWhwASFrqr9UUQeSUOUBP03MBrDc5MRc1eFhdqwi2 GLMITDv.iIfx5lzvdzsN1h4HOozK4WTXRKPDGwnHy0Xk.76tTDj705lOGmFV D2P4ooLAG1hPJNYt.XTyJW6MkINZ..1lPkb9HjxfPa1JfG0NGohJUMzFeGuB Vfmo_7OrYPF1UD1iuhZMXXvIg1ln1C7w990zoPLkg X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: zsh-users@zsh.org In-reply-to: From: Oliver Kiddle References: To: rahul Subject: Re: Implementing a menu (list) in a zsh script (as in command line) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23668.1356951604.1@thecus.kiddle.eu> Date: Mon, 31 Dec 2012 12:00:35 +0100 Message-ID: <23676.1356951635@thecus.kiddle.eu> rahul wrote: > 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 with: _complete() { [[ "$compstate[insert]" = tab* ]] && compstate[insert]="${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' Oliver