Maybe I'm not using the right terminology in my question, therefore I'll elaborate here with a clear example.
You can send the output of a command to the command line utility fzf, and if the former is still running, fzf lets you know it showing a "loading icon" and being refreshed live. For a clear example:
for i in `seq 1 5`; do echo $i; sleep 1 ; done | fzf
Now, I'd like to understand how fzf knows that the stream is not yet finished. And related but going beyond, I'd like to be able to do the same but passing through a file.
for i in `seq 1 5`; do echo $i; sleep 1 ; done > file.txt &
How can I take the content of file.txt and send it live to fzf? I have tried fzf < file.txt but it sends a static version of the file, as it is in the moment of writting the command. It does not let it live.
When the
readsystem calls returns0. Seeman 3 read.fzfcalls thereadsystem call and stays inside the system call until there is something to return. When there is something to read, the execution of the program continues.Interactive behavior is achieved by spawning threads (in
go). One thread waits on thereadsystem call. The other displays your "icon" or handles user input from/dev/tty.Typically,
tail -fis used to "follow" the end of a file while outputting the content.