jethrokuan / fzf

Ef-🐟-ient fish keybindings for fzf
MIT License
863 stars 65 forks source link

Changing FZF candidate list on the fly #127

Closed karthink closed 4 years ago

karthink commented 4 years ago

Is there a way to change the list of candidates that fzf is working with from within the selection window itself?

Here is an example of what I mean:

  1. I press Alt-c and start searching through directories.
  2. I realize that I need to search through a different list, such as the history of directories visited in that session (provided by $dirprev in fish), or a list obtained by starting find from a different root folder.
  3. I want to be able to press a command set with --bind=alt-r:execute(some-other-fzf-command) and start there instead.

Another example:

  1. My Ctrl-t command finds files using fd, starting at the home directory.
  2. I realize what I'm looking for is actually in /usr/share, so I want to switch to using locate by hitting alt-l.

But calling fzf (with a different source list) from within fzf doesn't seem to work. I realize that calling execute(..) may be the wrong way to go about it. So is there some recipe to switch sources on the fly without having to leave fzf and invoke a separate command from the shell?

karthink commented 4 years ago

I jumped the gun here. The fzf maintainer explains how to (not) do this:

https://github.com/junegunn/fzf/issues/416

I got the desired behavior in my examples above by combining the --expect option and some bash scripting.