summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2020-04-14 19:49:00 +0200
committerlassulus <lassulus@lassul.us>2020-04-14 19:49:00 +0200
commit843a537bd7fbedd8eb5fd61a1172dd8229440606 (patch)
tree33e250edbebaab5156c42ffc4535767263df63dc
parent1ed6cb71685a9aee1cdb91bee661365d8ce4eba8 (diff)
l fzfmenu: show query if no match
-rw-r--r--lass/5pkgs/fzfmenu/default.nix26
1 files changed, 18 insertions, 8 deletions
diff --git a/lass/5pkgs/fzfmenu/default.nix b/lass/5pkgs/fzfmenu/default.nix
index bdae8ceed..a158eeaac 100644
--- a/lass/5pkgs/fzfmenu/default.nix
+++ b/lass/5pkgs/fzfmenu/default.nix
@@ -32,14 +32,24 @@ pkgs.writeDashBin "fzfmenu" ''
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 \
- --print-query \
- --prompt=\"$PROMPT\" \
- > \"$OUTPUT\"" 2>/dev/null
+ if [ -z ''${TERM+x} ]; then #check if we can print fzf in the shell
+ ${pkgs.rxvt_unicode}/bin/urxvtc \
+ -name fzfmenu -title fzfmenu \
+ -e ${pkgs.dash}/bin/dash -c \
+ "echo \"$INPUT\" | ${pkgs.fzf}/bin/fzf \
+ --history=/dev/null \
+ --print-query \
+ --prompt=\"$PROMPT\" \
+ --reverse \
+ > \"$OUTPUT\"" 2>/dev/null
+ else
+ echo "$INPUT" | ${pkgs.fzf}/bin/fzf \
+ --history=/dev/null \
+ --print-query \
+ --prompt="$PROMPT" \
+ --reverse \
+ > "$OUTPUT"
+ fi
${pkgs.coreutils}/bin/tail -1 "$OUTPUT"
${pkgs.coreutils}/bin/rm "$OUTPUT"
''