Skip to content

Instantly share code, notes, and snippets.

@MahouShoujoMivutilde
Last active October 26, 2023 13:05
Show Gist options
  • Save MahouShoujoMivutilde/b1fa83bc234b68dd164cb6e843965d75 to your computer and use it in GitHub Desktop.
Save MahouShoujoMivutilde/b1fa83bc234b68dd164cb6e843965d75 to your computer and use it in GitHub Desktop.
fzf as dmenu replacement

fzf as dmenu replacement

Why? ...Because it's faster.

So you'll need:

  1. terminal that launches fast and supports custom class or window name. St fits the bill perfectly.

  2. window manager with an option to automatically put windows in center based on class or name. Most seem to have it.

#!/usr/bin/env bash
# fzfmenu - fzf as dmenu replacement
input=$(mktemp -u --suffix .fzfmenu.input)
output=$(mktemp -u --suffix .fzfmenu.output)
mkfifo $input
mkfifo $output
chmod 600 $input $output
# it's better to use st here (starts a lot faster than pretty much everything else)
# the ugly printf | sed thing is here to make args with quotes work.
# (e.g. --preview='echo {1}')
# sadly we can't use "$@" here directly because we are inside sh -c "..." call
# already
st -c fzfmenu -n fzfmenu -e sh -c "cat $input | fzf $(printf -- " '%s'" "$@" | sed "s/^ ''$//") | tee $output" & disown
# handle ctrl+c outside child terminal window
trap "kill $! 2>/dev/null; rm -f $input $output" EXIT
cat > $input
cat $output
@eylles
Copy link

eylles commented Sep 29, 2023

@RayZ0rr interesting, i have a repo that sees occasional commits https://github.com/eylles/fzfmenu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment