Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: The zsh equivalent to Bash's "complete -W" to complete a command using only a list of words



Hi Mr. Stephenson!

thanks for your reply.

On Sat, Apr 9, 2016 at 2:45 PM, Peter Stephenson <p.stephenson@xxxxxxxxxxx>
wrote:

> On Sat, 09 Apr 2016 13:27:39 +0300
> Shlomi Fish <shlomif@xxxxxxxxx> 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
>

In addition to that I was told on IRC that I can do this:

    compdef "_values $description $val1 $val2 $val3 $val4..." Theme

Where $description is a short description and $val1 $val2 are the values.

Thanks again.

Regards,

-- Shlomi

-- 
------------------------------------------
Shlomi Fish http://www.shlomifish.org/

Chuck Norris helps the gods that help themselves.

Please reply to list if it's a mailing list post - http://shlom.in/reply .


Messages sorted by: Reverse Date, Date, Thread, Author