yazi
yazi copied to clipboard
find: automatically open/enter when there is one match
Please describe the problem you're trying to solve
Similar to the find
command in ranger, if there's only a single match in the results the matched file or directory will automatically be entered/opened. This saves pressing the enter key two times.
Would you be willing to contribute this feature?
- [ ] Yes, I'll give it a shot
Describe the solution you'd like
A new argument for find
command that allows automatically executing another command, such as smart-enter, when there is one match remaining. The user is also put back into normal mode after.
The config might look something like the following
keymap = [
{ on = [ "f" ], run = ["find --smart --exec-on-single-match", "plugin --sync smart-enter"], desc = "Find next file, and automatically enter if there's a singular match" },
]
Additional context
No response
This is not feasible. find
completes immediately after execution and immediately executes the plugin
command following it.
It simply opens an input and does not block to wait for user input. In fact, all commands in Yazi are asynchronous, so state dependencies between such commands are not a reasonable design.
This is not feasible.
find
completes immediately after execution and immediately executes theplugin
command following it.It simply opens an input and does not block to wait for user input. In fact, all commands in Yazi are asynchronous, so state dependencies between such commands are not a reasonable design.
Thanks for the input. I think that's reasonable, especially if the find
command only finds the next match instead of every match. I've thought of the following alternatives as well
- When running
find
and in the[input]
keymap, allow use of theenter
or smart-enter command like{ on = [ "<Enter>" ], run = ["close", "enter"], desc = "Submit the selection" }
to open the first match. This reduces the enter keypresses by 1. - Add a
--max-depth-1
flag to jump, specifically for fzf. This reduces the enter keypresses by 1. - Implement another command ex.
find_enter
that will search the entire directory and auto open/navigate if there's one match. Will async be a problem with this as well? I'm also not sure if it's possible to 'interrupt' the user out of the input mode
This might make more sense to implement as a plugin. Going to close for now.
Sorry for the late reply, this is a reasonable need, but I need some time to think about how to better implement it, reopening
Hi, I made a plugin for it that extends the existing filter - it will automatically enter the only directory, and I've also added other enhancements, like supporting continuous filtering and automatically opening the hovered file on submitting:
https://github.com/sxyazi/yazi/assets/17523360/0007e5e5-ed9e-4104-ad13-0678b73af1f1
Feel free to use it: https://github.com/yazi-rs/plugins/tree/main/smart-filter.yazi
I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.