Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Completing all possible candidates

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