mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-17 15:53:39 -05:00
fzf as dmenu replacement example
38
Examples.md
38
Examples.md
@@ -53,7 +53,7 @@ Table of Contents
|
||||
* [i3](#i3)
|
||||
* [man pages](#man-pages)
|
||||
* [Python Behave BDD](#python-behave-bdd)
|
||||
|
||||
* [fzf as dmenu replacement](#fzf-as-dmenu-replacement)
|
||||
|
||||
|
||||
### General
|
||||
@@ -1399,4 +1399,38 @@ fbehave() {
|
||||
--bind 'enter:execute(echo {} | cut -f2 | pbcopy )' \
|
||||
--bind 'tab:execute(echo {} | cut -f1 | awk "{\$1=\$1};1" | pbcopy )'
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
### 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](https://st.suckless.org/) 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.
|
||||
|
||||
|
||||
```sh
|
||||
#!/usr/bin/env sh
|
||||
# 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)
|
||||
st -c fzfmenu -n fzfmenu -e sh -c "cat $input | fzf | tee $output" & disown
|
||||
|
||||
# handle ctrl+c outside child terminal window
|
||||
trap "kill $! 2>/dev/null" EXIT
|
||||
|
||||
cat > $input
|
||||
cat $output
|
||||
rm -f $input $output
|
||||
```
|
||||
|
||||
Don't forget to add a float/center rule for `fzfmenu` class/name to your wm's config.
|
||||
Reference in New Issue
Block a user