summaryrefslogtreecommitdiffstats
path: root/lass/5pkgs/fzfmenu/default.nix
blob: 6b589935929e317b74898241bd42f3d7976a55d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{ pkgs, ... }:

pkgs.writeDashBin "fzfmenu" ''
  set -efu
  PROMPT=">"
  for i in "$@"
  do
  case $i in
      -p)
      PROMPT="$2"
      shift
      shift
      break
      ;;
      *)
      echo "Unknown option $1"
      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 \
        --no-sort \
        --prompt=\"$PROMPT\" \
        > \"$OUTPUT\"" 2>/dev/null
  ${pkgs.coreutils}/bin/cat "$OUTPUT"
  ${pkgs.coreutils}/bin/rm "$OUTPUT"
''