Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completions from file with zcompsys
- X-seq: zsh-users 22740
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx, zsh-users@xxxxxxx
- Subject: Re: Completions from file with zcompsys
- Date: Tue, 20 Jun 2017 10:27:27 -0700
- Cc: dominik.vogt@xxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject:cc :mime-version; bh=khLQm80V9wRXwtyBhMnlK+Zb+aVdOJcILvA8grhetr4=; b=uoz+UIjc9UUKRJrboQ4/oNsEItQbiSUXYB3/pw3WumgtQUuSkd05HckPpu/WDqdemN mxoFdTNrV3Fsru0Oo0gzd2Cqz/K8nOYvDAyCrFkL4fZT1zBuj+ntHy8QauqLuZKJZwLL T+74NBUB550knQB3W8213F6FRMFKFb34uHH6uBNMlEFMsx5Q7tac8Yw2uq/0Ve+VuDr7 /ueRwY9ZkZkrIlaq3vggoE3InpuZKAbFe0bjssr3HyC5jUuDfzZ52qjcpLAwqO1qPhYY bS4TeHceRB3qOXx/O+1TuDCGLgtJRZFPMyZcv7P+Ev/FAxg66BN3stkx/qvWARvTDvH3 PdzQ==
- In-reply-to: <20170620074605.GA3709@gmx.de>
- 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: <20170620074605.GA3709@gmx.de>
On Jun 20, 8:46am, Dominik Vogt wrote:
}
} Are there some quick instructions instructions or a
} cheat sheet on the new completion system somewhere?
http://zsh.sourceforge.net/Guide/zshguide06.html#l144 (perhaps?)
} And I want to type things like
}
} $ foo Cheno<TAB>alb<TAB> # -> Chenopodium album
} $ foo Che*a<TAB> # -> Chenopodium a
}
} (using menu completion, not expanding the * to all matching
} completions).
The latter one could be tricky because you will have to prevent the "*"
from being expanded as a file glob.
Do you want the expansions exactly as you wrote them, or should the
spaces be quoted? E.g. do you want to end up with something like one
of
$ foo 'Chenopodium album'
$ foo Chenopodium\ album <-- this one is the easy one below
or instead
$ foo Chenopodium album
?? The latter will be a bit more work because you will have to account
for the first word when completing the second word.
In any case, the procedure is to create a function that produces a list
of words and then passes them to the "compadd" builtin. The list does
not have to be filtered against the command line (except in the "a bit
more work" case I just mentioned) because compadd will take care of
that part. Then you pass the names of that function and of the command
to the "compdef" function.
You can also pass a string to be eval'd to compdef, so the simplest answer
to your question is (guessing at a file name)
compdef 'compadd ${(f)"$(<~/latin-plant-names.txt)"}' foo
Then to get the "*"-expansion you will need to add the _match function
to your completer zstyle. Example might be
zstyle ':completion:*' completer _complete _match
but adjust the placement of _match to fit whatever your current list of
completers contains. It would normally be anywhere after _complete.
If the above doesn't satisfy, we can go into more detail about how to
change or remove the quoting.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author