Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Completing all possible candidates
- X-seq: zsh-users 17552
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Completing all possible candidates
- Date: Fri, 11 Jan 2013 12:30:56 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=9q/gFNlnFEHIS+MLm4vz0WvY3u4urYEd/5wAShSJR+k=; b=NSnFkj2xNvI75h12bBs1XakhtPJU/4PNZgOdLiOj24VYaXoCYwHLwnak4GmU7BCBmv HI7BXKSB3nsPxBNBhXj0TObLxkdT0omHJxA6B7MiqEwDCQ0zFrd7KcJx0FZ6+qKGqudw hV6CaL2G3wzfiLq1fxb9HABUzQcxho1sN3LBpdGt0gP2iHTG04hnv9X1ihwmIskHqv+k /tpjoaUihqTaaS7GsvDD4983R9Q5MKO1Cwq+eoqz5Zhy9MDefavzv6xF43VO3qxN4IZn Nf9hA+nfBadgxPnTknusKsBq21AaIweLg8vndz7Sg7nSN/Wf18ej7pdq+QnUDseCMd3/ HpyA==
- 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
For quite a while, I've used the following when I want completion from the
output of a previous command:
_my-prev-result() {
local hstring
# Run last command again, save output
hstring=$(eval $(fc -l -n -1))
# Split items on new-line into an array, quote each item
compadd - ${(@f)hstring}
}
zle -C my-prev-comp menu-complete _my-prev-result
bindkey '\ee' my-prev-comp
zle -C my-rev-prev-comp reverse-menu-complete _my-prev-result
bindkey '\eE' my-rev-prev-comp
This allows me to for example use "locate foo", and then complete the next
command with the found files (the drawback is of course that the previous
command could take a while to run). I know about the "keeper" functions in
the zsh distribution, but this is simpler.
Anyway, I recently realized that I sometimes could have use for putting ALL
the possibilities on the command line with a keystroke, à la the
"all-matches" example under _all_matches in the zsh manual.
In fact, I suspect the _all_matches completer should be involved somehow,
but I have failed to find out how.
Simply stated, I want a key that says: "run the previous command line, and
put all the resulting output on the command line". How to do this?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author