fzy icon indicating copy to clipboard operation
fzy copied to clipboard

Idea: Empty output if no matches

Open aude opened this issue 6 years ago • 6 comments

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?

aude avatar Feb 01 '19 12:02 aude

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:

  • `Return' confirms the current selection
  • `Shift-Return' confirm the input

E.g.:

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

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

iamleot avatar Feb 01 '19 12:02 iamleot

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?

aude avatar Feb 01 '19 13:02 aude

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 pressing Shift+Return') the same of what happens in fzy: `c' is printed out.

iamleot avatar Feb 02 '19 08:02 iamleot

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?

aude avatar Feb 07 '19 12:02 aude

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

jhawthorn avatar Dec 28 '19 07:12 jhawthorn

@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.

zvezdochiot avatar Dec 28 '19 09:12 zvezdochiot