1
0
mirror of https://github.com/kmein/niveum synced 2026-03-20 20:01:08 +01:00

fix(fzfmenu): include bash and handle options

This commit is contained in:
Kierán Meinhardt
2020-04-15 14:58:23 +02:00
parent 7010bbb0e8
commit 9020ae67c8
2 changed files with 24 additions and 2 deletions

View File

@@ -111,7 +111,7 @@ in
fzfmenu = wrapScript { fzfmenu = wrapScript {
script = ./fzfmenu.sh; script = ./fzfmenu.sh;
name = "fzfmenu"; name = "fzfmenu";
packages = [ pkgs.st pkgs.fzf pkgs.dash ]; packages = [ pkgs.st pkgs.fzf pkgs.dash pkgs.bash ];
}; };
bvg = pkgs.callPackage ./bvg.nix {}; bvg = pkgs.callPackage ./bvg.nix {};

View File

@@ -9,10 +9,32 @@ mkfifo "$input"
mkfifo "$output" mkfifo "$output"
chmod 600 "$input" "$output" chmod 600 "$input" "$output"
for i in "$@"; do
case $i in
-p)
PROMPT="$2"
shift
shift
break ;;
-l)
# no reason to filter number of lines
shift
shift
break ;;
-i)
# we do this anyway
shift
break ;;
*)
echo "Unknown option $1" >&2
shift ;;
esac
done
# it's better to use st here (starts a lot faster than pretty much everything else) # it's better to use st here (starts a lot faster than pretty much everything else)
st -c fzfmenu -n fzfmenu -g 85x10 \ st -c fzfmenu -n fzfmenu -g 85x10 \
-e dash \ -e dash \
-c "cat $input | fzf --print-query $* | tee $output" & disown -c "cat $input | fzf --reverse --prompt='${PROMPT+> }' --print-query $* | tee $output" & disown
# handle ctrl+c outside child terminal window # handle ctrl+c outside child terminal window
trap 'kill $! 2>/dev/null; rm -f $input $output' EXIT trap 'kill $! 2>/dev/null; rm -f $input $output' EXIT