zsh-users / zaw

zsh anything.el-like widget.
BSD 3-Clause "New" or "Revised" License
572 stars 67 forks source link

zaw from stdin ? #72

Closed bradparks closed 8 years ago

bradparks commented 8 years ago

Hey! I'm using zaw to search my history, and love it there...

Is there anyway to let zaw accept input from stdin? ie use it as an interactive grep ?

For example, I'd like to do something like this:

instead of the following to find files with both "it" and "test" in their names:

find . | grep it | grep test

I'd like to see if I could use zaw to select the files, like:

find . | zaw

if I run this, then zaw takes stdin and allows me to select items from stdin by doing interactive searches. Once selected, then zaw outputs the contents to the cmd line. Maybe it rewrites the command as

find . | zaw it test

I know this is fuzzy and not exactly how zaw works, but it seems to me that it could fit this use case somehow... kind of like https://github.com/mooz/percol

willghatch commented 8 years ago

Your wish is my command. Well, since it was convenient, at least, and I suddenly realized that that would be a great source to add. I'm not sure what to do with the selected one aside from append it to buffer. Maybe there should be a way to print out all the candidates that are still valid after the current filters. But for now you get to see the output lines and choose one via filtering.

bradparks commented 8 years ago

Awesome! it seemed to me like it might be relatively easy to add, by someone who speaks zaw... Thank you mighty one!

dekz commented 8 years ago

Is it possible to chain this together like in the original issue? That is:

ls | zaw

I seem to be able to run zaw then choose command-output then enter ls, but not pipe the input through stdin.

willghatch commented 8 years ago

That might be difficult. Zaw is registered as a ZLE widget, which means it can't be called normally, but rather only by keyboard shortcut or by another ZLE function. I'm not sure how to get around that.