I have the following bash script that I'd like to use as a fuzzy file opener. I create a fifo, spawn a new terminal with fzf running and redirect fzf's output to the fifo. I then call a function that reads from the fifo and opens the files.
My problem is that the while loop inside the open
function never ends. How can I close the fifo once all the lines have been read?
#!/usr/bin/env bash
FIFO=/tmp/fuzzy-opener
[ -e "$FIFO" ] || mkfifo "$FIFO"
exec 3<> "$FIFO"
function open {
while read file; do
# open every $file based on its mime-type
done <&3
echo 'done' # this is never reached
}
alacritty -e sh -c "fzf -m >&3"
&& open
fzf
and the format of its output. Make sure soleread
is what you want. – Kamil Maciorowski Apr 01 '21 at 13:15