fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit 576ed77ab0067d24fdd67cde9b30eb71c8a8af78
parent 19e0d195d2e9635b879af466f9c7c73380234496
Author: John Hawthorn <john@hawthorn.email>
Date:   Sun, 17 Jun 2018 11:58:09 -0700

Fix reading choices if stdin is a tty

Previously we deferred reading choices to after initializing the tty.
This makes sense only when stdin and our tty aren't the same.

Diffstat:
Msrc/fzy.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/fzy.c b/src/fzy.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <ctype.h> #include <limits.h> +#include <unistd.h> #include "match.h" #include "tty.h" @@ -39,10 +40,15 @@ int main(int argc, char *argv[]) { } } else { /* interactive */ + + if (isatty(STDIN_FILENO)) + choices_fread(&choices, stdin); + tty_t tty; tty_init(&tty, options.tty_filename); - choices_fread(&choices, stdin); + if (!isatty(STDIN_FILENO)) + choices_fread(&choices, stdin); if (options.num_lines > choices.size) options.num_lines = choices.size;