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



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



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