fd icon indicating copy to clipboard operation
fd copied to clipboard

My .fdignore and .config/fd/ignore seem to be not working

Open khlsvr opened this issue 4 years ago • 2 comments

I installed fd with pacman on arch linux. I did add the following in .bash_profile but I guess they are irrelevant anyway. When I search with plain fd I get results from directories included in the ~/.fdignore

export FZF_DEFAULT_COMMAND='fd --color=always --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS="--ansi"
export FZF_ALT_C_COMMAND="fd -t d ."
[x@x ~]$  fd --version
fd 8.2.1
[x@x ~]$  pwd
/home/x
[x@x ~]$  cat .fdignore 
/home/x/.opam
/home/x/files/karjalainen/

[x@x ~]$  cat .config/fd/ignore 
/home/x/.opam
/home/x/.npm
/home/x/files/karjalainen
[x@x ~]$  fd karjala | head -4
raja-karjalan_korpus
files/karjalainen
files/karjalainen/1929-03-19_Karjalainen_-_19-03-1929_print.pdf
files/karjalainen/1947-02-11_Karjalainen_-_11-02-1947_print.pdf

khlsvr avatar May 06 '21 06:05 khlsvr

Thank you for reporting this. I can confirm this. The problem is with the absolute paths.

For your local .fdignore file, you should be able to fix this by making the paths relative:

.opam
files/karjalainen/

this is because .fdignore works similar to .gitignore where the current directory is the "root".

As for the global .config/fd/ignore file... absolute paths should be supported here. Experimenting with this, I found a behavior that should definitely be considered a bug: If you use the -a/--absolute-path option of fd, the folders are actually ignored(!). This option is supposed to only modify the appearance of the search results.

sharkdp avatar Aug 07 '21 20:08 sharkdp

excluded pattern didn't work too.

❯ cat ~/.config/fd/ignore
.git/

.cache/
!.cache/yay/
!.cache/paru/

.local/share/cargo
.local/share/go
.local/share/yarn

node_modules/
dist/
out/
.next/

❯ pwd
/home/latipun

❯ l .cache
Permissions Size User    Date Modified Name
drwxr-xr-x     - latipun  8 Jun  7:15   asp
drwxr-xr-x     - latipun  8 Jun  8:32   bat
drwxr-xr-x     - latipun 25 Jan 19:37   chezmoi
drwxr-xr-x     - latipun 18 Jul 18:53   fontconfig
drwxr-xr-x     - latipun 18 Jul 20:44   git
drwxr-xr-x     - latipun 25 Jan 21:22   gitstatus
drwxr-xr-x     - latipun 25 Jan 19:25   go-build
drwxr-xr-x     - latipun 25 Jul 18:33   heroku
drwxr-xr-x     - latipun 26 Jul 16:33   lvim
drwxr-xr-x     - latipun 25 Jul 18:30   node-gyp
drwxr-xr-x     - latipun 25 Jan 19:34   npm
drwx------     - latipun 18 Jul 23:51   nvim
drwxr-xr-x     - latipun 26 Jul 16:26   p10k-latipun
drwxr-xr-x     - root    19 Jul 13:07   p10k-root
drwxr-xr-x     - latipun 12 Apr  0:13   yarn
drwxr-xr-x     - latipun 21 Jul 15:43   yay
drwx------     - latipun 24 Jul  7:43   zsh
.rw-------  156k latipun 26 Jul 16:26   p10k-dump-latipun.zsh
.r--r--r--  347k latipun 26 Jul 16:26   p10k-dump-latipun.zsh.zwc
.rw-------  124k root    19 Jul 13:07   p10k-dump-root.zsh
.r--r--r--  281k root    19 Jul 13:07   p10k-dump-root.zsh.zwc
.rw-------   20k latipun 23 Jul 18:23   p10k-instant-prompt-latipun.zsh
.r--r--r--   54k latipun 23 Jul 18:23   p10k-instant-prompt-latipun.zsh.zwc
.rw-------   20k root    19 Jul 13:02   p10k-instant-prompt-root.zsh
.r--r--r--   54k root    19 Jul 13:02   p10k-instant-prompt-root.zsh.zwc

❯ fd -H yay
.config/nvim/sessions/%home%latipun%.cache%yay%kmscon-patched-git.vim
.config/yay/
.local/bin/yay-remove-hook
.local/bin/yay-upgrade-hook
.local/share/chezmoi/home/dot_local/bin/executable_yay-remove-hook
.local/share/chezmoi/home/dot_local/bin/executable_yay-upgrade-hook

❯ fd -H fd | head -1
./.config/fd/

~/.cache/yay should be found, but other directory inside ~/.cache still ignored. Since !.cache/yay/ on the ignore file, and ! means that pattern should be excluded from ignore.

latipun7 avatar Jul 26 '22 09:07 latipun7