1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00
Files
niveum/packages/scripts/fzfmenu.sh

20 lines
594 B
Bash
Raw Normal View History

2020-04-10 15:06:15 +02:00
#!/usr/bin/env bash
# fzfmenu - fzf as dmenu replacement
# https://github.com/junegunn/fzf/wiki/Examples#fzf-as-dmenu-replacement
2020-04-10 16:18:20 +02:00
set -efu
2020-04-10 14:53:16 +02:00
2020-04-10 15:06:15 +02:00
input=$(mktemp -u --suffix .fzfmenu.input)
output=$(mktemp -u --suffix .fzfmenu.output)
mkfifo "$input"
mkfifo "$output"
chmod 600 "$input" "$output"
2020-04-10 14:53:16 +02:00
2020-04-10 15:06:15 +02:00
# it's better to use st here (starts a lot faster than pretty much everything else)
st -c fzfmenu -n fzfmenu -g 85x15 -e sh -c "cat $input | fzf $* | tee $output" & disown
# handle ctrl+c outside child terminal window
trap 'kill $! 2>/dev/null; rm -f $input $output' EXIT
cat > "$input"
cat "$output"