-
-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--exclude
doesn't work with absolute paths
#851
Comments
Hi! I would like to work on this. :) I'm gonna try to fix it and open a PR. |
The issue here is as follows: the exclude option works the same way .gitignore patterns work. This means that an absolute path is relative to the root of the git repo (which is the first search path in our case). To fix this, we can check which exclude options are absolute and filter the results after crate |
Just ran into this problem. Thanks for the tip, @alessandroasm. In my case I made the excluded paths relative to the root folder, and it worked. Perhaps the man page could be updated to note that the flag follows the same rules as ignore entries. |
Especially bad in combination with ~
❯ fd --exclude Containers --follow |wc -l
2657140
~ took 8s
❯ fd --follow |wc -l
38664223
~ took 1m10s
❯ I don't really want to add plain My current approach, for everyone wanting sth similar, is this rather granular global ignore, which allows me to find files living in these containers (sandboxed apps' documents) while not blowing up completely: # Source:
~/Library/Containers
❯ fd --type symlink |cut -d '/' -f 4 |sort |uniq
# $XDG_CONFIG_HOME/fd/ignore
Library/Containers/*/Data/Desktop
Library/Containers/*/Data/Downloads
Library/Containers/*/Data/Library
Library/Containers/*/Data/Movies
Library/Containers/*/Data/Music
Library/Containers/*/Data/Pictures
# Result:
~
❯ fd --follow |wc -l
2702849
~ took 9s
❯ |
@alessandroasm any progress on this? If you've encountered any difficulty or cannot spare the time, I am willing and able to help. |
Hello cyqsimon, sadly I'm way too busy at this time, so I could not get any
progress on this. Fell free to work on it if you want :)
…On Fri, Aug 5, 2022 at 7:29 AM cyqsimon ***@***.***> wrote:
@alessandroasm <https://github.com/alessandroasm> any progress on this?
If you've encountered any difficulty or cannot spare the time, I am willing
and able to help.
—
Reply to this email directly, view it on GitHub
<#851 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWVKXYWDAAZDXH7J3XJUODVXT3LFANCNFSM5D3VSVZA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I would have liked this feature, too. If it's a performance or compatibility concern we could have an --exclude-abs option, that would then do a check if it's a file in the current search directory. |
It's more of a "the library we use for this doesn't really support this". So we would have to find a way to work around that, or stop using that library. See BurntSushi/ripgrep#2366 |
I finally have some time to come back to this issue. From reading https://github.com/sharkdp/fd/blob/master/src/walk.rs, it seems like there is no good way to implement an "ignore by absolute path" mechanism within the confines of the So considering the performance impact, would it make some sense to split "absolute ignore" into its own flag, and implement it independently of what's offered by As of the specific implementation, I imagine it won't be too difficult (if some performance penalty is acceptable). In I'll quickly put together a prototype to test. Any ideas/suggestions are welcomed! |
Another problem related to this is that
There's no way to exclude just the ❯ fd --exclude exclude-me
directory/
directory/just-some-file EDIT: Never mind, my use case does not require any additional features. Pre-pending the pattern with a slash anchors it to the root directory: ❯ fd --exclude /exclude-me
directory/
directory/exclude-me
directory/just-some-file |
So using relative paths with prepended slash solves this issue. |
No, we still can't use absolute paths |
In my case, I want to search multiple directories and exclude specific directories, I don't think this is possible with fd currently |
Describe the bug you encountered:
The examples for the
--exclude
or-E
option imply that it should work with absolute paths (/mnt/external-drive
is given as an example). However, it only seems to work with relative paths. For example, if I'm trying to exclude the directory/home/user/Library/
:works, as does
However,
doesn't work (i.e.
/home/user/Library/pattern.txt
would still show up in search results ). Adding other options, such as-p
or-a
doesn't seem to affect this behavior.The only way I've found to exclude absolute paths is to add them to
~/.config/fd/ignore
, which is sowewhat inconvenient.What version of
fd
are you using?Which operating system / distribution are you on?
The text was updated successfully, but these errors were encountered: