gokcehan / lf

Terminal file manager
MIT License
7.73k stars 332 forks source link

Add `on-find` command (mimic `ranger`'s `find` command) #1135

Open Andrew15-5 opened 1 year ago

Andrew15-5 commented 1 year ago

I want to mimic ranger's find command, which will auto open a directory if the find command successfully found one. I'm not 100% sure, but ranger have set incsearch by default (at least this feature exists). In short, I want to do this:

cmd on-find $lf -remote "send $id open"
# or
cmd on-find open # I don't know if this is a valid syntax

The reason is simple: this way I can press 1 less key after each find. Because I do this pretty often, and it became annoying to press l after each search pretty quickly (and there is no workaround except maybe changing the code).

Right now I can't find any way to do this. If I send find and open commands, they will be executed "simultaneously" and not "one finished (successfully), next executed".

Note: In incremental search (find) the selected entry may be changed, and it mustn't trigger on-find command. OR there could be 2 commands: on-find (on each entry change) on-find-success/on-successful-find and I'm interested only in the last one.

As an alternative, I propose an option that controls whether to auto-open (dir and/or file) after a successful search or not.

Andrew15-5 commented 1 year ago

Not always, you would know at which keystroke the find command will be completed, therefore an auto-open feature will visually notify you that the find command has been completed. I tend to overshoot by keep on typing the characters which may end up being a map command instead of string provided to find command. This simple mistake can cause a huge problem if the keys you press are mapped to a destructive command.

Maybe adding an optional delay to input blocking/ignore (which is customizable in milliseconds) after find command was finished can be a nice little but very helpful feature.

Andrew15-5 commented 1 year ago

I think this is all the settings I have regarding the find command:

set incsearch
set anchorfind!
set findlen 0