Fzf: A few suggestions

Created on 18 Apr 2016  路  7Comments  路  Source: junegunn/fzf

  • Category

    • [x] fzf binary

    • [ ] fzf-tmux script

    • [ ] Key bindings

    • [ ] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [ ] Linux

    • [x] Mac OS X

    • [ ] Windows

    • [ ] Etc.

  • Shell

    • [] bash

    • [x] zsh

    • [ ] fish

  1. file list caching
    It seems that fzf load file list every time from scratch.
    Ctrl-t in my home directory, there are almost 2M files and it takes almost 2 minutes.
    I hope file list caching will be added.
  2. filter or exclude pattern
    When I am in my home directory, I rarely want to search files in Applications/ or Library/.
    How about reading exclude pattern in fzf conf file something like this?

$ cat > ~/.fzf.conf exclude Applications/ exclude Library/

  1. Ctrl-t like Ctrl-r
    I think this is a natural usage, but it won't work that I expected.

$ vi some/parent/dir/<Ctrl-t>

I expected that fzf would show files under some/parent/dir/ or its descendant dirs.
Furthermore, It would be very handy if fzf supports auto-completion like this:

$ vi s/p/d/<Ctrl-t>

Most helpful comment

Thanks for the suggestion.

Regarding point 1 and 2, let me put it this way: fzf can be thought of as _an interactive version of grep_. Does grep cache the input? No. And grep does know the meaning of the text it's processing. It's designed to "not care" about the context. The same can be said about fzf.

seq 1000 | fzf
git tag | fzf
ps -ef | fzf
find . | fzf

You see, fzf cannot decide whether if it makes sense to cache the input, or if some extra pre-filtering is appropriate or not. It all depends on the context but fzf is designed to be a context-free filter just like grep. So in that sense, it's beyond the scope of this project.

What you can do instead is to write a script that caches the output of find and use it as the input to fzf. The users should know better about their systems and their needs.

find-cached | filter-irrelevant | fzf

# or
export FZF_DEFAULT_COMMAND='fzf-cached | filter-irrelevant'
fzf

(There's also $FZF_CTRL_T_COMMAND.)

Many users including myself use ag as their FZF_DEFAULT_COMMAND:

export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'

ag also allows you to extend its filtering rule with .agignore file, so you might want to check it out.

https://github.com/ggreer/the_silver_searcher/wiki/Advanced-Usage

The behavior you described in point 3 is available via fuzzy completion (vim some/parent/dir/**<tab>) and if you use zsh, you can configure CTRL-T to act as the dedicated key for fuzzy completion. You can find the details in this page.

$ vi s/p/d/

I'm not against the idea as long as we can have the same behavior both on bash and zsh (I myself am a bash user). Pull requests are appreciated.

All 7 comments

  1. caching was already discussed in previous issues, it's outside the scope of fzf which is just a filter, not a source and not a source management system.
  2. FZF_DEFAULT_OPTS and other env vars exist for that purpose. Use your normal shell rc or vimrc.

@justinmk With 1. and 2., what I am trying to tell you is how to speed up loading file list with exclude pattern, not how to filter out some exclude pattern within file list.
I have checked the fzf man page, but I can't find how I can set the exclude pattern.
Please tell me what I have misunderstood.

I totally agree with you on 3. I've always missed that and it felt very natural to have such a behavior. Maybe it could be made configurable (something you can turn off).

Thanks for the suggestion.

Regarding point 1 and 2, let me put it this way: fzf can be thought of as _an interactive version of grep_. Does grep cache the input? No. And grep does know the meaning of the text it's processing. It's designed to "not care" about the context. The same can be said about fzf.

seq 1000 | fzf
git tag | fzf
ps -ef | fzf
find . | fzf

You see, fzf cannot decide whether if it makes sense to cache the input, or if some extra pre-filtering is appropriate or not. It all depends on the context but fzf is designed to be a context-free filter just like grep. So in that sense, it's beyond the scope of this project.

What you can do instead is to write a script that caches the output of find and use it as the input to fzf. The users should know better about their systems and their needs.

find-cached | filter-irrelevant | fzf

# or
export FZF_DEFAULT_COMMAND='fzf-cached | filter-irrelevant'
fzf

(There's also $FZF_CTRL_T_COMMAND.)

Many users including myself use ag as their FZF_DEFAULT_COMMAND:

export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'

ag also allows you to extend its filtering rule with .agignore file, so you might want to check it out.

https://github.com/ggreer/the_silver_searcher/wiki/Advanced-Usage

The behavior you described in point 3 is available via fuzzy completion (vim some/parent/dir/**<tab>) and if you use zsh, you can configure CTRL-T to act as the dedicated key for fuzzy completion. You can find the details in this page.

$ vi s/p/d/

I'm not against the idea as long as we can have the same behavior both on bash and zsh (I myself am a bash user). Pull requests are appreciated.

The behavior you described in point 3 is available via fuzzy completion (vim some/parent/dir/**)

Wow, didn't know that! That helps a lot, thank you!

@junegunn Thank you for your kind reply.

I agree with the point that fzf binary should remain in the same scope with grep.
But grep doesn't do key binding such as Ctrl-t or Ctrl-r.
I thought the functionalities could be added as shell integration extensions.

I have switched from bash into zsh, and I realized how handy tab completions are.
I think vi s/p/d/<Ctrl-t> is much cooler than vi some/parent/dir/**<tab>.

Anyway, I'll try more configurations that you suggested.
And thank you for fzf.

@dongminkim Yeah I see your point, but the way I see it, they are optional and not the core part of the project. They are there to give you the idea of how fzf can be used to extend the functionality of shell and to get you started with fzf, but I don't plan to add more to them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erusev picture erusev  路  3Comments

nordlow picture nordlow  路  3Comments

leonklingele picture leonklingele  路  3Comments

aleclarson picture aleclarson  路  3Comments

chrisamow picture chrisamow  路  3Comments