Skip to content

Add a --only-restricted to not show search results other than ignored and hidden files #1894

@juarezr

Description

@juarezr

Overview

Currently, fd can filter hidden/ignored files from search results according to the following flags:

  • --ignore, --no-ignore, --no-ignore-vcs: Show/omit search results from files and directories ignored by rules/patterns in '.gitignore', '.ignore', '.fdignore', or the global ignore files.
  • --hidden, --no-hidden: Show/omit search results from hidden dot files.
  • --unrestricted: Show both the ignored and hidden files.

This gives us two kinds of results:

  1. A "restricted" mode with the paths matched by the search patterns but without the files/folders in hidden/ignored paths.
  2. A "mixed" mode with all the paths matched by the search patterns, disregarding when it is or isnt't in a hidden/ignored path.

Proposal

  • Add a new flag like --only-restricted to filter out files/folders that are not under ignore/hidden paths.
  • This will yield a third mode where the search result will omit "restricted" entries but will show files/folders that are under ignore/hidden paths.
  • This new flag can also be combined with flags --no-ignore and --hidden to further restrict the search results.

Use cases

  • Searching only in hidden folders like $XDG_CONFIG_HOME ($HOME/.config/)
  • Searching only non-committed files under .gitignore rules in Git repositories

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestignore-forkThis would benefit from using a custom fork of the ignore crate.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions