fzy icon indicating copy to clipboard operation
fzy copied to clipboard

Enable multi-select

Open gpanders opened this issue 6 years ago • 13 comments

This enables multi-select in fzy with the Ctrl+t key. Pressing Ctrl+t on an item will make that item bold. Pressing Ctrl+t will de-select it. When at least one item is multi-selected, pressing the Return key will print each multi-selected item on its own line to stdout (this mimics the behavior of fzf's multi-select feature).

EDIT: Updated the key binding to Ctrl+t.

gpanders avatar Oct 14 '19 00:10 gpanders

Nice work! I only want to point out that Ctrl-s is an unfortunate shortcut, because pressing Ctrl-s makes my terminal hang (and requires pressing Ctrl-q to unblock it). While searching for what's going on I discovered that running stty -ixon disables the "hang" functionality and therefore allows fzy to intercept and react on pressing Ctrl-s, but given that many people would probably stumble upon this issue as well, maybe we can choose a more "friendly" default shortcut.

max-baz avatar Oct 15 '19 13:10 max-baz

Ahhh, the tyranny of control flow. Admittedly, I forgot about this anti-feature as I haven't personally run into it in quite some time.

You're right of course that Ctrl-s will not work while control flow is still enabled by default in most terminals/shells. Some other alternative bindings I considered are Ctrl-t, Ctrl-f, and Ctrl-Space.
Of these I think I would prefer Ctrl-t because it has the mnemonic of "tag". Any thoughts here?

On Tue, 15 Oct 2019 at 01:24:37 PM +0000, Maxim Baz wrote:

Nice work! I only want to point out that Ctrl-s is an unfortunate shortcut, because pressing Ctrl-s makes my terminal hang (and requires pressing Ctrl-q to unblock it). While searching for what's going on I discovered that running stty -ixon disables the "hang" functionality and therefore allows fzy to intercept and react on pressing Ctrl-s, but given that many people would probably stumble upon this issue as well, maybe we can choose a more "friendly" default shortcut.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jhawthorn/fzy/pull/124#issuecomment-542209768

gpanders avatar Oct 15 '19 14:10 gpanders

I would probably vote for Ctrl+Space as it's easier to type, but Ctrl+t sounds OK too.

Have you considered moving the selection down when you press the "select" shortcut? So that when you run echo 'a\nb\nc\nd' | ./fzy pressing Ctrl+Space three times would select a, b and c?

max-baz avatar Oct 15 '19 14:10 max-baz

Here's a small bug I discovered:

  1. Run echo 'a\nb\nc\nd' | ./fzy
  2. Type aa<Ctrl-s><Backspace><Enter>
[1]    566797 done                              echo 'a\nb\nc\nd' | 
       566798 segmentation fault (core dumped)  ./fzy

max-baz avatar Oct 15 '19 14:10 max-baz

I'm not able to reproduce this - are you up-to-date on the multiselect branch of my fork? I did make some updates after my initial commit, some of which addressed a few memory-related bugs.

On Tue, 15 Oct 2019 at 07:14:58 AM -0700, Maxim Baz wrote:

Here's a small bug I discovered:

  1. Run echo 'a\nb\nc\nd' | ./fzy
  2. Type `aa<Ctrl-Space><Backspace><Enter>
[1]    566797 done                              echo 'a\nb\nc\nd' |
      566798 segmentation fault (core dumped)  ./fzy

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jhawthorn/fzy/pull/124#issuecomment-542234314

gpanders avatar Oct 15 '19 14:10 gpanders

I was on master but I switched to multiselect branch and still can reproduce this every time

max-baz avatar Oct 15 '19 14:10 max-baz

What is printed for you in this case, aa?

max-baz avatar Oct 15 '19 14:10 max-baz

  1. I enter aa as the search query, so that there are no choices available that match the query
  2. I press the multi-select key
  3. I press <Backspace> so that the query is now simply a. The a choice reappears
  4. I press <Enter> and a is returned (that being the only choice)

On Tue, 15 Oct 2019 at 07:22:20 AM -0700, Maxim Baz wrote:

What is printed for you in this case, aa?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jhawthorn/fzy/pull/124#issuecomment-542237927

gpanders avatar Oct 15 '19 14:10 gpanders

Thanks, with the latest code everything works well now, and I love how Ctrl-t scrolls and even wraps to the first entry when you select the last one 👍

Great job!

max-baz avatar Oct 15 '19 14:10 max-baz

Is this gonna be merged to master?

fszymanski avatar Feb 12 '21 14:02 fszymanski

@jhawthorn

Any update on when/if this will be pushed into master? This is a great feature.

alexchomiak avatar Feb 22 '21 18:02 alexchomiak

Why was C-t chosen over the tab key (what fzf uses)?

Soundtoxin avatar Sep 06 '22 03:09 Soundtoxin