fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Limit search by delimiter (e.g. slashes between directories)

Open Pistos opened this issue 5 years ago • 3 comments

  • Category
    • [x] fzf binary
    • [ ] fzf-tmux script
    • [ ] Key bindings
    • [ ] Completion
    • [ ] Vim
    • [ ] Neovim
    • [ ] Etc.
  • OS
    • [x] Linux
    • [x] Mac OS X
    • [ ] Windows
    • [ ] Windows Subsystem for Linux
    • [ ] Etc.
  • Shell
    • [x] bash
    • [x] zsh
    • [ ] fish

My feature request is probably best explained by an example. Given the following lines:

app/models/foo/bar/baz.rb
app/models/foo/bar-baz.rb
app/models/foo-bar-baz.rb
app/monsters/dungeon/foo/bar/baz.rb

(Using the default fuzzy searching mode), if I type app/mod/fo/ba/baz, I want fzf to filter down to app/models/foo/bar/baz.rb, and not include any of the others.

In other words, if I know in my head the dir structure of my project, and I want to get at a file that is under a specific subtree in the repo, I want to be able to use slashes to trim fzf's result set.

As fzf is now, when I type app/mod, it matches both app/models and app/monsters/dungeon because the letters mo are in monsters and d is in dungeon.

Pistos avatar Oct 01 '19 16:10 Pistos

some combination of -e (exact) -d (specify / as delimiter) and --with-nth to specify nesting level of the delimiter maybe what you are after? i.e. cat $filelist | fzf -e -d '/' --with-nth=5

shedali avatar Dec 13 '19 23:12 shedali

@shedali Thanks for your suggestion. I couldn't get it to do what I wanted, though.

Pistos avatar Dec 16 '19 20:12 Pistos

I can get close, but not quite, with fzf -n .. -d /. It still cuts across multiple directories.

Pistos avatar Oct 05 '22 20:10 Pistos

Closing as wontfix, because the matching algorithm of fzf is not specifically designed for file paths. Including app/monsters/dungeon in the result doesn't seem like a problem because it's ranked lower than the rest. And you can use exact matching by prefixing the term with '. e.g. 'app/mod f--

junegunn avatar Jul 07 '24 08:07 junegunn