Skip to content

Add directory support to --type-add (or equivalent) #3339

@Firehed

Description

@Firehed

Describe your feature request

I would like a way to leverage the type filters (-t/-T) combined with directories. I've discovered (through trial and error, then checking the source) that the globbing for --type-add only seems to match files, not entire paths.

Use-case: I keep a number of --type-add flags in my ~/.ripgreprc for categorizing common types across projects and languages. One that I use frequently is test (almost the inverse of the src example from the manpage) based on common filenames.

# Create a "test" type for common test files, typically for use with -t/-T
--type-add=test:*.test.*
--type-add=test:*Test.*
--type-add=test:*Tests.*

While this catches a pretty good amount of test infrastructure, it frequently misses things like fixtures and other supporting files, in addition to some unconventionally-named test files. While I realize the --glob flag can have an equivalent effect per-invocation, I find a lot of utility value in quickly running rg foo -Ttest and having it pre-set through my rc file to cover 99% of cases.

I checked for open issues/requests and didn't see anything that covered this, although there were a couple older ones in adjacent areas that were closed due to lack of feedback.

Thanks for considering this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions