Fzf: Ignore some dirs

Created on 18 Oct 2015  路  9Comments  路  Source: junegunn/fzf

How to ignore some dirs? Likes node_modules in Node.js project.

question

Most helpful comment

You can also just use :GFiles instead of :Files, seeing as node_modules is usually in the .gitingore file. This is in case you are using it in vim.

nnoremap <c-p> :GFiles<cr>

All 9 comments

Filtering irrelevant entries is not a responsibility of fzf since fzf is just a dumb filter and does not know the context. You can use something like ag for that.

See https://github.com/junegunn/fzf#respecting-gitignore-hgignore-and-svnignore

@junegunn Regarding the .gitignore settings you mention above... where I do I set/run the commands you list?

# Feed the output of ag into fzf
ag -g "" | fzf

# Setting ag as the default source for fzf
export FZF_DEFAULT_COMMAND='ag -g ""'

# Now fzf (w/o pipe) will use ag instead of find
fzf

# To apply the command to CTRL-T as well
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"

@jdsimcoe Set up FZF_DEFAULT_COMMAND in your shell configuration file (e.g. .bashrc, .zshrc, etc.)

@junegunn Did that and it worked. Thanks!

You can also just use :GFiles instead of :Files, seeing as node_modules is usually in the .gitingore file. This is in case you are using it in vim.

nnoremap <c-p> :GFiles<cr>

@samiralajmovic Keep in mind that :GFiles is not equivalent to setting $FZF_DEFAULT_COMMAND. See https://github.com/junegunn/fzf.vim/issues/121#issuecomment-466056060 for more information.

install ripgrep with your package manager:
$ brew install ripgrep

update your env variable:
export FZF_DEFAULT_COMMAND='rg --files'

had issues with GFiles, worked with it for a while, but everytime the need to add files was a bummer...

I find that :GFiles doesn't take into account unchecked files. Does anyone have a solution to that?

@Lilja If with "unchecked files" you mean files not added to git, see the comment 2 above yours.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nordlow picture nordlow  路  3Comments

olethanh picture olethanh  路  3Comments

jberglinds picture jberglinds  路  3Comments

skamsie picture skamsie  路  3Comments

ahmedelgabri picture ahmedelgabri  路  3Comments