fzy

terminal fuzzy finder picker

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

commit 5d391103f3031ca9a1ba43a87115486ee994884a
parent 3c6ba5c8f550da5d049bc5fcbf044304c4b7a166
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Fri, 11 Jul 2014 21:24:53 -0700

Output the result on Enter

Diffstat:
Mfzy.c | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/fzy.c b/fzy.c @@ -131,6 +131,22 @@ void draw(){ fflush(ttyout); } +void emit(){ + int i; + for(i = 0; i < choices_n; i++){ + double rank = match(search, choices[i]); + if(rank > 0){ + /* Output the first match */ + printf("%s\n", choices[i]); + exit(EXIT_SUCCESS); + } + } + + /* No match, output the query instead */ + printf("%s\n", search); + exit(EXIT_SUCCESS); +} + void run(){ draw(); char ch; @@ -153,7 +169,7 @@ void run(){ draw(); }else if(ch == 10){ /* Enter */ clear(); - exit(0); + emit(); }else{ printf("'%c' (%i)\n", ch, ch); }