From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11013 invoked by alias); 9 Apr 2016 11:56:05 -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: 21434 Received: (qmail 13714 invoked from network); 9 Apr 2016 11:56:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-AuditID: cbfec7f5-f792a6d000001302-7e-5708eb73f2b2 Date: Sat, 09 Apr 2016 12:45:53 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: The zsh equivalent to Bash's "complete -W" to complete a command using only a list of words Message-id: <20160409124553.783683a3@pwslap01u.europe.root.pri> In-reply-to: References: Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t/xa7rFrznCDdb9kLPYcXIlowOjx6qD H5gCGKO4bFJSczLLUov07RK4Mnrm/mUpeMla8WL7NPYGxuMsXYwcHBICJhKvG1y7GDmBTDGJ C/fWs3UxcnEICSxllLg44TgThDONSeL4mn/sEM5pRom/a/4xQjhnGCVavi9iAulnEVCVONvy kwXEZhMwlJi6aTYjiC0iICqxfMVmdpB1wgJZEnOu6YCYvAL2Eu+es4NUcAoES7Tv/QtmCwkE SDzecRfM5hfQl7j69xMTxHX2EjOvnAGbyCsgKPFj8j2wTcwCWhKbtzWxQtjyEpvXvGWGmKMu cePubvYJjMKzkLTMQtIyC0nLAkbmVYyiqaXJBcVJ6blGesWJucWleel6yfm5mxghofx1B+PS Y1aHGAU4GJV4eAVCOMKFWBPLiitzDzFKcDArifAefgkU4k1JrKxKLcqPLyrNSS0+xCjNwaIk zjtz1/sQIYH0xJLU7NTUgtQimCwTB6dUAyOTQKrV/rIfrH8OV3WuuLtfTmRBX8XpOfHrmfZL zvjRasmueGdlVHjT/K8FaUZnOScsf2C3+ayPznFP57bHKwP/NszaN1uUUfP2P/5cUYP3x7aq reA8yDk5e1n81Egdt+i2GSdnfRFVsDAoO8HzMY971q5DJx+832LBvOrirwez60zjskufhRxW YinOSDTUYi4qTgQA0WPBkGECAAA= On Sat, 09 Apr 2016 13:27:39 +0300 Shlomi Fish wrote: > I am looking for the zsh equivalent of this bash command to complete a > command using a list of words: > > complete -W "$(cat ${__themes_dir}/list-of-themes.txt)" "Theme" > > In bash, I can do Theme[space][tab] and it will give me completions only > from the designated words / options / strings. Assuming you have the completion system already loaded, the following is a fairly standard way of doing it. The "_wanted" business makes it fit in with the standard conventions. pws _Theme() { local expl local -a themes themes=($(<${__themes_dir}/list-of-themes.txt)) _wanted tests expl -a themes } compdef _Theme Theme