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

[Enhancement] Type-ahead find #1118

Open
avidseeker opened this issue Feb 21, 2023 · 7 comments
Open

[Enhancement] Type-ahead find #1118

avidseeker opened this issue Feb 21, 2023 · 7 comments

Comments

@avidseeker
Copy link

avidseeker commented Feb 21, 2023

This is the default behavior for many file managers.

A dirty implementation is to cat >> ~/.config/lf/lfrc

# Nav
map <a-h> updir
map <a-j> down
map <a-k> up
map <a-l> open
map <enter> open
map <space> :toggle
map <c-w> quit
map <f-2> rename

map q push :find<enter>q
map w push :find<enter>w
map e push :find<enter>e
map r push :find<enter>r
map t push :find<enter>t
map y push :find<enter>y
...
@dase78
Copy link

dase78 commented Mar 5, 2023

I'm not sure if I understand you right, but there is already a quite nice way for this kind of search:
https://github.com/gokcehan/lf/wiki/Integrations#fzf

I simplified it for me a little and use fdfind:

cmd fzf-jump ${{ res="$(fdfind -H -c never | fzf --reverse --header='goto')" if [ -f "$res" ]; then cmd="select" elif [ -d "$res" ]; then cmd="cd" fi lf -remote "send $id $cmd \"$res\"" }}
Map the cmd to any key you like and bam!

@avidseeker
Copy link
Author

Of course, fuzzy find features are super helpful, but I'm trying to basically select files by their initials instead of having to enter a special command for that. I want selection to be the default mode.

@dase78
Copy link

dase78 commented Mar 5, 2023

I see. Right.

@cartok
Copy link

cartok commented Jan 23, 2024

Yea, I also miss it. Other than that, I think this is the best terminal file explorer out there. It would be good to have a navigation mode which can be enabled on start with some flag and also toggled during use.

It enables to type to navigate. Furthermore, it's basically only loop around the search function, which already exists.

An additional configurable option which makes it that it automatically enters a directory if there are no other possible matches for whatever you typed would also be great.

@dase78
Copy link

dase78 commented Jan 23, 2024

This would be similar to the navigation/finding in Midnight Commander, where you also can type along if you turn off the comand line.

Would surely be a nice option but only to implement with a shortcut not a single keystroke. The more I think about it, I'm not sure, if I would like it.

But anyways. Just my 5c.

@cartok
Copy link

cartok commented Jan 23, 2024

I like nnn's "type to search" mode. In lf, it would also be possible to choose whether the filter or the search command should be used. Usually when I open lf I want to navigate first and then do some actions, and it can really help and be more convenient to see the full UI, opposed to using fzf,ripgrep,fd,zoxide,z.lua etc.

When I'm in the right place, I would disable the mode with some shortcut like or anything you configure in lfrc - could also replace the default / with the mode toggle & same for filter.

The fd solutions are good when you're in some software project, but I would not want to use it on the full file system, because it would not work well everywhere, especially when you mount network file systems. I use rclone to mount Google Drive. When I execute fd or find inside on the parent level, I could wait for hours if I do not use --one-file-system or an ignore file with that folder hard-coded.

My fzf command is export FZF_DEFAULT_COMMAND='fd --strip-cwd-prefix --one-file-system --ignore-file ~/.config/fd/ignore' and I have quite a big ignore file, which is rather not a solution I can rely on all the time. That's why I looked out for a file manager for normal things. Maybe I can limit my fzf command to only go 3 levels wide and add some bindings to move forward tho.

@cartok
Copy link

cartok commented Jan 23, 2024

For now I will probably use the following configuration for navigation and will integrate fd+fzf and rg+fzf aswell.

# Kinda type-to-navigate but many spacebars and enters
map <enter> open
map <space> search
map <tab> :toggle; down

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

No branches or pull requests

3 participants