Fzf: Question: Including hidden files in search

Created on 31 Aug 2015  路  19Comments  路  Source: junegunn/fzf

Haven't found an option for it. Maybe I'm missing something?

question

Most helpful comment

That allowed searching on .git as well. So this was the final command I ended up using for future reference:

let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -l -g ""'

All 19 comments

find . | fzf

export FZF_DEFAULT_COMMAND='find .'
fzf

makes sense?

EDIT: oops, typo.

Thanks for the quick response, I am currently using:

let $FZF_DEFAULT_COMMAND = 'ag -l -g ""'

In my .nvimrc, how would I also incorporate that?

No idea, man ag :)

Got it. Needed to add the --hidden flag.

That allowed searching on .git as well. So this was the final command I ended up using for future reference:

let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -l -g ""'

My 2 cents : you don't need -l if you already have -g

@netei that works, thanks for the tip.

What if one wants to search including only one hidden directory? (I want to include .vim, but including all hidden files seems to slow this tool down.)

Just in case anyone's using ripgrep the command line equivalent is:

rg --hidden -l "" | fzf

and the zshrc line is:

export FZF_DEFAULT_COMMAND='rg --hidden -l ""'

My 2 cents. With:

ag --hidden --ignore .git -g ""

you don't get directory names, only file names. I decided to use:

find . -printf "%P\\n"

for both FZF_DEFAULT_COMMAND and FZF_CTRL_T_COMMAND

Not sure why you would use ag or rg to find files instead of find. Running the three options on my local machine i can see that find is the fastest, and is massively faster than rg.

$ sudo time find . -type f -not -path '*/\.git/*' | wc -l
2.40user 3.21system 0:05.67elapsed 99%CPU (0avgtext+0avgdata 7464maxresident)k
0inputs+0outputs (0major+11502minor)pagefaults 0swaps
1401803
$ sudo time rg --hidden -l "" | wc -l
13.25user 47.54system 0:33.70elapsed 180%CPU (0avgtext+0avgdata 316396maxresident)k
17791040inputs+0outputs (0major+95227minor)pagefaults 0swaps
697078
$ sudo time ag --hidden --ignore .git -l -g "" | wc -l
2.86user 3.20system 0:06.27elapsed 96%CPU (0avgtext+0avgdata 3664maxresident)k
9112inputs+0outputs (1major+1193minor)pagefaults 0swaps
990647

Not sure why you would use ag or rg to find files instead of find

For common usage, it's quicker to write, just that.

Because they respect .gitignore.

Using fishshell I had to put the following in ~/.config/nvim/init.vim: let $FZF_DEFAULT_COMMAND = "find -L"

Taken from alx741 on reddit.

To my understanding, fzf is a generic fuzzy finder. It's up to user to provide pool to fzf (via STDIN, find, fd, ag, ripgrep, ps, ls etc). It's just that fzf uses ubiquitous find internally by default. My point is that option to include hidden files in search result is relevant to those provider utils like find, thus this is not a right place to open issue here.

Can anyone explain why you would use rg --hidden -l "" for FZF instead of rg --hidden --files? Using the latter seems to make rg about as fast as find I've found:

$ time rg --hidden --files | wc -l
0.12user 8.76system 0:01.30elapsed 682%CPU (0avgtext+0avgdata 10372maxresident)k
0inputs+0outputs (0major+2695minor)pagefaults 0swaps
14877
$ time rg --hidden -l "" | wc -l
0.40user 27.75system 0:10.81elapsed 260%CPU (0avgtext+0avgdata 15220maxresident)k
0inputs+0outputs (0major+4232minor)pagefaults 0swaps
11442
$ time find . | wc -l
0.15user 2.85system 0:03.02elapsed 99%CPU (0avgtext+0avgdata 1564maxresident)k
0inputs+0outputs (0major+500minor)pagefaults 0swaps
51994

My 2 cents : you don't need -l if you already have -g

I even had a [$FZF_DEFAULT_COMMAND failed] when both -g and -l were present. Ended up removing -g to make it work. Using it in .zshrc

For anyone looking for ripgrep solution that shows hidden files but ignore .git folder here's the code:

export FZF_DEFAULT_COMMAND='rg --files --hidden -g "!.git" '

It's just that fzf uses ubiquitous find internally by default. My point is that option to include hidden files in search result is relevant to those provider utils like find, thus this is not a right place to open issue here.

This doesn't sound true to me. It could only be true if fzf invoked it with some option to ignore hidden files, which isn't documented in the man page, and would anyway shift responsibility for this behavior to fzf.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aleclarson picture aleclarson  路  3Comments

skamsie picture skamsie  路  3Comments

jan-warchol picture jan-warchol  路  3Comments

leonklingele picture leonklingele  路  3Comments

sassanh picture sassanh  路  3Comments