Fzf: How can I force fzf to ignore multiple directories?

Created on 1 Jul 2019  路  4Comments  路  Source: junegunn/fzf

  • Category

    • [x] fzf binary

  • OS

    • [x] Linux

  • Shell

    • [x] zsh

fzf version: 0.18.0

Question

As the title says, I would like to know how I can ignore multiple directories in fzf?
For example, I would ignore node modules and the .git folder.

How can I do this?

question

Most helpful comment

fzf acts like an interactive filter. Default search program is find, but can be changed via FZF_DEFAULT_COMMAND
It's recommended to use silver searcher or ripgrep, which are faster and respect ~/.gitignore.

For example: after installing above program, following can be added in ~/.bashrc:

#determines search program for fzf
if type ag &> /dev/null; then
    export FZF_DEFAULT_COMMAND='ag -p ~/.gitignore -g ""'
fi
#refer rg over ag
if type rg &> /dev/null; then
    export FZF_DEFAULT_COMMAND='rg --files --hidden'
fi

then put whatever you want to ignore in ~/.gitignore:

###################
.DS_Store
.hg
.svn
*.vscode
node_modules
###################
# Temporary files
*.kate-swp
*.swp
*.swo
*~

you can search in Issues with keywords: exclude, ignore file/folders. There are multiple threads about this. Here is some info:
https://github.com/junegunn/fzf#respecting-gitignore
https://github.com/junegunn/fzf/issues/128

All 4 comments

fzf acts like an interactive filter. Default search program is find, but can be changed via FZF_DEFAULT_COMMAND
It's recommended to use silver searcher or ripgrep, which are faster and respect ~/.gitignore.

For example: after installing above program, following can be added in ~/.bashrc:

#determines search program for fzf
if type ag &> /dev/null; then
    export FZF_DEFAULT_COMMAND='ag -p ~/.gitignore -g ""'
fi
#refer rg over ag
if type rg &> /dev/null; then
    export FZF_DEFAULT_COMMAND='rg --files --hidden'
fi

then put whatever you want to ignore in ~/.gitignore:

###################
.DS_Store
.hg
.svn
*.vscode
node_modules
###################
# Temporary files
*.kate-swp
*.swp
*.swo
*~

you can search in Issues with keywords: exclude, ignore file/folders. There are multiple threads about this. Here is some info:
https://github.com/junegunn/fzf#respecting-gitignore
https://github.com/junegunn/fzf/issues/128

What if the project/folder doesn't have .gitignore?
For example, when I am in the home directory, how can I ignore some folders?

WITHOUT .gitignore.

What if the project/folder doesn't have .gitignore?

It's not local .gitignore but ~/.gitignore which can be specified via core.excludesFile
.
Git respects it inside any git project and above programs also ignore it's pattern but globally

For example, when I am in the home directory, how can I ignore some folders?

As mentioned before when you want to exclude file/folder, you need to do it in the command which pipe the output to fzf!

Yeah, thanks...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lbeier picture lbeier  路  3Comments

fenuks picture fenuks  路  3Comments

alistaircolling picture alistaircolling  路  3Comments

natemara picture natemara  路  3Comments

firedev picture firedev  路  3Comments