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

zi automatically selects only initial result #1022

Closed

Conversation

azaleacolburn
Copy link
Contributor

Description

zi foo will now automatically select the only initial result if applicable, as per #997.

Usage

The command zoxide query --interactive foo will now automatically select the only result initially returned, if there is only one. If there is initially more than one result, but further fuzzy-finding narrows it down to just one, that final result will not be automatically selected.

Environment Variable

A new environment variable _ZO_ZI_ONLY_RESULT has been introduced which toggles the behavior described above with the current behavior of zi.

@ajeetdsouza
Copy link
Owner

Hey @azaleacolburn, thanks for sending in these PRs. I really appreciate the help! One small request though - can you tag me before picking up something? I may have a different implementation in mind, so I could probably save you some time there.

For this particular issue, I think this would be the cleanest solution:

  • Currently, zoxide uses certain default flags for fzf, which the user can override with _ZO_FZF_OPTS.
  • We can add a flag called _ZO_FZF_OPTS_EXTRA that adds flags on top of the default ones, rather than replacing them.
  • Once that works, users can get this behaviour with the following setup:
export _ZO_FZF_OPTS_EXTRA="--select-1"

@ValJed
Copy link

ValJed commented Mar 24, 2025

@ajeetdsouza @azaleacolburn Just seing this PR and your answer, funny but I just opened a PR to support _ZO_FZF_EXTRA_OPTS.
#1026

I can rename the flag if you prefer.

@azaleacolburn
Copy link
Contributor Author

@ajeetdsouza Thank you! I'll be sure to tag you going forward. I didn't realize the --select-1 option existed. I agree that it's clearly the cleanest solution. I'll close this PR and respond to #997 letting them know about #1026 and the select-1 flag.

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

Successfully merging this pull request may close these issues.

3 participants