#!/bin/sh -e
#
# deps: floating-terminal (kitty)

input="${TMPDIR:-/tmp}"/test-input
output="${TMPDIR:-/tmp}"/test-output
mkfifo -m 600 "${input}"
mkfifo -m 600 "${output}"
trap 'rm -f ${input} ${output}' EXIT

# FIXME(2022-05-11): this waits for $input to be closed before fzf shows anything
# see: https://overflow.adminforge.de/exchange/askubuntu.com/questions/1107617
floating-terminal -e sh -c 'fzf "$@"'" <${input} >${output}" fzf "$@" &

# on linux, can use /proc instead of setting up our own fifos
# floating-terminal -e sh -c 'fzf "$@"'" < /proc/$$/fd/0 > /proc/$$/fd/1" fzf "$@"

cat >"${input}"
cat "${output}"
