I want to poll something and then pipe results to FZF, such that it gets updated there. Here is an example using CURL:
while true; do curl google.com -s; sleep 2; done | fzf
This stacks-up all the outputs like:
</BODY></HTML>
<A HREF="http://www.google.com/">here</A>.
The document has moved
<H1>301 Moved</H1>
<TITLE>301 Moved</TITLE></HEAD><BODY>
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
</BODY></HTML>
<A HREF="http://www.google.com/">here</A>.
The document has moved
<H1>301 Moved</H1>
<TITLE>301 Moved</TITLE></HEAD><BODY>
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
</BODY></HTML>
<A HREF="http://www.google.com/">here</A>.
The document has moved
<H1>301 Moved</H1>
<TITLE>301 Moved</TITLE></HEAD><BODY>
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
But I want it to just list one output
</BODY></HTML>
<A HREF="http://www.google.com/">here</A>.
The document has moved
<H1>301 Moved</H1>
<TITLE>301 Moved</TITLE></HEAD><BODY>
> <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
and update it if it changes.
A simple way of dealing with this is with a key-press-reload command:
But that requires pressing CTRL-R to refresh. To make it automated... can wrap the desired command and FZF, and use FZF with
fzf -f <query>to only get the results to display. Eg, with node create fzf-watch.js:Call it like this to watch the results (called every 5 seconds):