mirror of
https://github.com/kmein/niveum
synced 2026-03-19 11:31:09 +01:00
feat(i3): improve fzfmenu
This commit is contained in:
@@ -27,7 +27,7 @@ in with config.niveum; {
|
|||||||
commands = [
|
commands = [
|
||||||
{
|
{
|
||||||
command = "floating enable";
|
command = "floating enable";
|
||||||
criteria = { title = "fzfmenu"; };
|
criteria = { class = "fzfmenu"; };
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ in
|
|||||||
fzfmenu = makeScript {
|
fzfmenu = makeScript {
|
||||||
src = ./fzfmenu.sh;
|
src = ./fzfmenu.sh;
|
||||||
name = "fzfmenu";
|
name = "fzfmenu";
|
||||||
propagatedBuildInputs = [ pkgs.alacritty pkgs.fzf ];
|
propagatedBuildInputs = [ pkgs.st pkgs.fzf ];
|
||||||
};
|
};
|
||||||
|
|
||||||
bvg = pkgs.callPackage ./bvg.nix {};
|
bvg = pkgs.callPackage ./bvg.nix {};
|
||||||
|
|||||||
@@ -1,40 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
set -efu
|
# fzfmenu - fzf as dmenu replacement
|
||||||
PROMPT="fzfmenu: "
|
# https://github.com/junegunn/fzf/wiki/Examples#fzf-as-dmenu-replacement
|
||||||
|
|
||||||
for i in "$@"; do
|
input=$(mktemp -u --suffix .fzfmenu.input)
|
||||||
case $i in
|
output=$(mktemp -u --suffix .fzfmenu.output)
|
||||||
-p)
|
mkfifo "$input"
|
||||||
PROMPT="$2"
|
mkfifo "$output"
|
||||||
shift
|
chmod 600 "$input" "$output"
|
||||||
shift
|
|
||||||
break ;;
|
|
||||||
-l)
|
|
||||||
# no reason to filter number of lines
|
|
||||||
LINES="$2"
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
break ;;
|
|
||||||
-i)
|
|
||||||
# we do this anyway
|
|
||||||
shift
|
|
||||||
break ;;
|
|
||||||
*)
|
|
||||||
echo "Unknown option $1" >&2
|
|
||||||
shift ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
INPUT=$(cat)
|
# it's better to use st here (starts a lot faster than pretty much everything else)
|
||||||
OUTPUT="$(mktemp)"
|
st -c fzfmenu -n fzfmenu -g 85x15 -e sh -c "cat $input | fzf $* | tee $output" & disown
|
||||||
alacritty \
|
|
||||||
--title fzfmenu \
|
# handle ctrl+c outside child terminal window
|
||||||
--dimensions 85 15 \
|
trap 'kill $! 2>/dev/null; rm -f $input $output' EXIT
|
||||||
-e sh -c \
|
|
||||||
"echo \"$INPUT\" | fzf \
|
cat > "$input"
|
||||||
--history=/dev/null \
|
cat "$output"
|
||||||
--no-sort \
|
|
||||||
--prompt=\"$PROMPT\" \
|
|
||||||
> \"$OUTPUT\"" 2>/dev/null
|
|
||||||
cat "$OUTPUT"
|
|
||||||
rm "$OUTPUT"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user