jhawthorn / fzy

:mag: A simple, fast fuzzy finder for the terminal
MIT License
2.98k stars 126 forks source link

Idea: Empty output if no matches #105

Open aude opened 5 years ago

aude commented 5 years ago

Currently, if I pipe in some lines to fzy, input the garble oSh3ahngah1e and press Enter, this happens:

$ ls | fzy
oSh3ahngah1e

I think I would prefer no output in case there is no match:

$ ls | fzy

I would be easier to use together with a Bash widget I use, that opens a fuzzy find file dialog via rg and fzy. Then I'd rather get no output than incorrect output for the filename.

What do you think?

iamleot commented 5 years ago

Hello Asbjørn,

Asbjørn Apeland writes:

Currently, if I pipe in some lines to fzy, input the garble oSh3ahngah1e and press Enter, this happens:

$ ls | fzy
oSh3ahngah1e

I think I would prefer no output in case there is no match:

$ ls | fzy

I would be easier to use together with a Bash widget I use, that opens a fuzzy find file dialog via rg and fzy. Then I'd rather get no output than incorrect output for the filename.

What do you think? [...]

I would find it a bit strange because it would limit the fzy output to its piped input instead of giving the freedom to type and output a possible user's input.

I like the dmenu behaviour where:

E.g.:

% printf "foo\nfooo\nbar\nbaz\n" | dmenu

Typing f' and pressingReturn' will confirm foo' (the first selection), like fzy. Typingf' and pressing Shift-Return' will just outputf'.

aude commented 5 years ago

That makes sense to me.

The point I am interested in is, in your example, what happens if I type c?

If I press Return, I would want empty output, as there is no selection (because nothing matches c). If I press Shift+Return, it might be a good idea to just output c. It sounds like you've got more experience than me there.

What do you think about that?

iamleot commented 5 years ago

Asbjørn Apeland writes:

[...] That makes sense to me.

The point I am interested in is, in your example, what happens if I type c? I would want empty output, as there is no selection (because nothing matches c).

What do you think about that? [...]

In dmenu (both if pressing Return' or if pressingShift+Return') the same of what happens in fzy: `c' is printed out.

aude commented 5 years ago

That is true, that's what happens in dmenu.

I would personally like if it behaved differently. Is that a possibility, or do you think it will not happen?

jhawthorn commented 4 years ago

Good idea. I would accept a PR which added --only-exact (or something similar) but I'd like to keep the default behaviour.

zvezdochiot commented 4 years ago

@jhawthorn say:

I would accept a PR which added --only-exact

They forgot to mention the use of fzy, which requires an exact match:

cd /usr/bin
$(ls | fzy)

--only-exact is needed.