stockholm/lass/5pkgs/fzfmenu/default.nix

46 lines
875 B
Nix
Raw Normal View History

2018-11-30 06:48:49 +00:00
{ pkgs, ... }:
pkgs.writeDashBin "fzfmenu" ''
set -efu
PROMPT=">"
for i in "$@"
do
case $i in
-p)
PROMPT="$2"
shift
shift
break
;;
2018-12-02 04:47:20 +00:00
-l)
# no reason to filter number of lines
LINES="$2"
shift
shift
break
;;
-i)
# we do this anyway
shift
break
;;
2018-11-30 06:48:49 +00:00
*)
2018-12-02 04:47:20 +00:00
echo "Unknown option $1" >&2
2018-11-30 06:48:49 +00:00
shift
;;
esac
done
INPUT=$(${pkgs.coreutils}/bin/cat)
OUTPUT="$(${pkgs.coreutils}/bin/mktemp)"
${pkgs.rxvt_unicode}/bin/urxvt \
-name fzfmenu -title fzfmenu \
-e ${pkgs.dash}/bin/dash -c \
"echo \"$INPUT\" | ${pkgs.fzf}/bin/fzf \
--history=/dev/null \
2020-01-11 20:00:57 +00:00
--print-query \
2018-11-30 06:48:49 +00:00
--prompt=\"$PROMPT\" \
> \"$OUTPUT\"" 2>/dev/null
2020-01-11 20:00:57 +00:00
${pkgs.coreutils}/bin/tail -1 "$OUTPUT"
2018-11-30 06:48:49 +00:00
${pkgs.coreutils}/bin/rm "$OUTPUT"
''