Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion from a given list
- X-seq: zsh-users 16091
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Completion from a given list
- Date: Fri, 10 Jun 2011 09:48:07 -0700
- In-reply-to: <20110609103107.GA5710@Xye>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20110609103107.GA5710@Xye>
On Jun 9, 4:01pm, Raghavendra D Prabhu wrote:
}
} I want to have a completion based on given list which may updated after
} every command is run.
Two ways to go about this. Both require that you create a function
that calls "compadd" with the list of words you want completed.
typedef -a _tmux_words
_tmux_list() {
compadd -a _tmux_words
}
Up to you to figure out how to populate the _tmux_words array. The
function that eventually calls compadd can do as much other work as
you like to decide whether to call compadd at all; see for example
the _expand_alias function in the zsh distribution. [*]
With that in place, you can do either:
(1) Create a key binding that invokes it, leaving normal completion
alone.
compdef -k _tmux_list complete-word ^XT
(2) Add a function to your "completer" style.
zstyle ':completion:*' completer _complete _tmux_list _correct
Don't use the above zstyle literally; find the one you are presently
using and insert _tmux_list at the point where you want those words
tried as possible completions.
[*] I picked _expand_alias because it's explicitly designed to be
usable as either a key binding or a completer entry. Note #compdef
at the top of the source file.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author