Is there a way to use a read filter that calls an interactive command?
My use case is a grep command that returns a long list of tags that I might want to include in a blog post; I was hoping to be able to filter it with fzf, something like:
:r ! grep foo bar.txt | fzf -m
Unfortunately this doesn't show the interactive fzf prompt, seems to freeze, and when killed with Ctrl-c reads a bunch of gibberish into the buffer.
Trying a more simple example, this reads foo into the buffer:
:r ! { myvar=foo; echo "${myvar}"; }
This doesn't work:
:r ! { read myvar; echo "${myvar}"; }
I thought perhaps it was an issue with stdin so I also tried (without success):
:r ! { read -u 3 myvar 3<&0; echo "${myvar}"; }
Am I going about this wrong?
:r !are written to a temporary file (whose contents are inserted into the buffer when execution completes). Using an interactive command when you can't see any output isn't very useful. :) – B Layer Nov 04 '21 at 16:24fzfanything and everything it writes to stdout or stderr (e.g. a copy of its listing for each time the list changes/refreshes) is going to be captured and inserted into the buffer. – B Layer Nov 04 '21 at 16:48:help filter. I wonder if there's a way to redirect the fzf output into the same temporary file. – n8henrie Nov 04 '21 at 17:35readI agree it's odd that it overwrites the current command line (even withclear;first), but it works great with fzf. – n8henrie Nov 04 '21 at 18:22:Agthat might be what you want. – mattb Nov 04 '21 at 18:27