junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.89k stars 2.41k forks source link

Feature: Enable to use builtin walker in reload function or create new reload-walker function #4062

Open petersladek opened 1 month ago

petersladek commented 1 month ago

I am using ctrt+t shell integration and in FZF_CTRL_T_OPTS I have set up reload function to switch between Directories and Files. Right now, I have to use custom command (e.g. fd) to list directories/files in reload functions, but I would prefer to use built-in walker as it is much faster! It would be great if I could use built-in walker with arguments --walker or --walker-skip in reload() function, or bind new function e.g. reload-walker().

junegunn commented 1 month ago

I've given some thought about that, but it's not clear how we can support three walker options in a single "reload-walker" action. A workaround currently available is to start fzf with --filter '' so that it immediately prints the candidates from its walker.

fzf --bind 'ctrl-d:reload:</dev/tty fzf --filter "" --walker dir' \
    --bind 'ctrl-f:reload:</dev/tty fzf --filter "" --walker file'

(</dev/tty is needed to trigger walker)

petersladek commented 1 month ago

Will try the workaround thanks!

junegunn commented 1 month ago

Admittedly, --filter '' < /dev/tty isn't pretty. Maybe we should provide a shortcut option for this.

# Start the built-in walker and print the list
fzf --walk

Or for better flexibility, we could just add --walker-force to replace < /dev/tty.

# Start built-in walker and print the list
fzf --walker-force --filter ''

# You can use --walker-force to use built-in walker even when
# * $FZF_DEFAULT_COMMAND is set
# * Standard input is not a tty device
export FZF_DEFAULT_COMMAND=ls
whoami | fzf --walker-force

These are just some initial ideas. I'm not going to rush into a decision.