Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to select single result immediately (revisit issue #27) #36

Closed
stephentalley opened this issue Apr 1, 2014 · 7 comments
Closed
Assignees
Labels

Comments

@stephentalley
Copy link

Issue 27 (#27) requested a --select-single
option to fzf to automatically select a match if there is only one.

While a workaround was provided, I think this is a common enough use case with a complex enough workaround to merit addition of the actual option.

I am using the fq1() workaround heavily, both in the shell but also in vimscript. Having to duplicate this in two places makes me wish I could just simplify both cases to a single --select-single argument.

Besides improving usability, not having to invoke fzf twice (as the workaround does) would preclude having to move large result sets around in memory and across processes, and save a second invocation of the fzf process. That could have a noticeable performance/memory improvement in some cases.

It may make sense to combine this with a --select-zero option to exit if no matches are found.

@junegunn
Copy link
Owner

junegunn commented Apr 2, 2014

I've given some thought about it over time, and have come to agree with the need for the option. You have nicely summarized the reasoning behind this. I'll keep you updated on the progress.

@junegunn junegunn self-assigned this Apr 2, 2014
@junegunn
Copy link
Owner

junegunn commented Apr 2, 2014

Okay, now we have --select-1 and --exit-0 option (or -1 and -0 respectively).
I've also updated fe example on the README page.
Could you update fzf and check if it works for you? Let me know if you see any problem.

(/cc @wellle)

@wellle
Copy link
Contributor

wellle commented Apr 2, 2014

👍 Looks great. I will upgrade soon.

@stephentalley
Copy link
Author

Wow, thanks for the quick response, Junegunn!

A few suggestions:

  • -1 should probably work regardless of whether --query is passed. That
    will allow the user to automatically select the only choice if
    $FZF_DEFAULT_COMMAND produces only one item.
  • -0 should probably also work regardless of whether --query is passed.
    This will allow the user to avoid having to quit out of a useless fzf
    session if no results were produced by $FZF_DEFAULT_COMMAND.
  • Consider returning 0 when exiting with the -0 option (it currently
    exits with 1) to distinguish it from the case where there were several
    matches, but the user pressed CTRL-C/ESC to exit the finder (which also
    exits with 1).

Thanks again, this is a great utility!

Steve

On Wed, Apr 2, 2014 at 8:51 AM, Christian Wellenbrock <
notifications@github.com> wrote:

[image: 👍] Looks great. I will upgrade soon.

Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-39325787
.

junegunn added a commit that referenced this issue Apr 2, 2014
- Make -0 and -1 work without -q
- Change exit status to 0 when exiting with -0
@junegunn
Copy link
Owner

junegunn commented Apr 2, 2014

Ah, those are great suggestions. I've changed their behavior as suggested. Thanks!

@stephentalley
Copy link
Author

Fantastic! Thanks again for putting together such a useful utility!

On Wed, Apr 2, 2014 at 12:08 PM, Junegunn Choi notifications@github.comwrote:

Ah, those are great suggestions. I've changed their behavior as suggested.
Thanks!

Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-39349413
.

@junegunn junegunn closed this as completed Apr 5, 2014
@wellle
Copy link
Contributor

wellle commented Apr 5, 2014

Works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants