Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion from a given list
- X-seq: zsh-users 16095
- From: Raghavendra Prabhu <raghu.prabhu13@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Completion from a given list
- Date: Mon, 13 Jun 2011 15:39:52 +0530
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jBxrR2nmRFDOfYuDcyXZnBdive1vw2pJGoG74ShI6ug=; b=I6BG7BoJMi+ADgAlld86IiKnxYDqoJyzPD3qNTFuDk1o9iNMAc5p7A6qLhFcTTW86q QeyedEcnY6xhrW+1VYH6XJsPM2AH1FPwNhyI4VacKI/xpJKNd3RkE+P/8JvYuTjeCROi xAWLYUx1f4T9qxtqQs8G9kdWFAKQFDZBQVc0Q=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=ayjmustUAAjcTZCuGSJw9mtnf7b6JEoja0dvNpHemDFVCIYuGzhB7QC5UlBhUJSf8H 1dfCU7umyVjxf52BvfZrrZGGdDlnzjhGXKtJdPyGwjz8SMLP3aNGkkPigb0kY0hD5M3P K5O07A4JcKaaKIB8R+dn/0vZWx6Na/vfHWa1U=
- In-reply-to: <110610094807.ZM31777@torch.brasslantern.com>
- 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> <110610094807.ZM31777@torch.brasslantern.com>
On Fri, Jun 10, 2011 at 10:18 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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.
>
Thanks, I will test this and reply back.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author