Skip to content

m-manu/scfind

Repository files navigation

scfind

Build and test Go Report Card Go Reference License

Why?

find command in unix-like OSes is great. But, it is not helpful in searching for source code files or in searching inside source code files (when used along with grep). So, we need a specialized command.

What?

scfind, which stands for 'source code find', is a replacement for find command for source code files. It's ultra light and very fast.

How to install?

  1. Install Go version at least 1.21
  2. Run command:
    go install github.com/m-manu/scfind@latest
  3. Add following line in your .bashrc/.zshrc file:
    export PATH="$PATH:$HOME/go/bin"

How to use?

Running scfind -h shows this help message:

scfind is a 'find' command for source code files

Usage: 
	scfind DIRECTORY_PATH

where,
	DIRECTORY_PATH is path to a readable directory that
	you want to scan for source code files

For more details: https://github.com/m-manu/scfind

Examples

scfind ~/Programming
scfind . | xargs grep --color "LinkedHashSet"

How does this work?

scfind command traverses file tree with source code awareness in following ways:

  1. Scans for files with known source code and configuration file extensions (case insensitive)
    • e.g..java, .go, .py, .yml etc.
    • see full list
  2. Scans for files with certain names (case sensitive)
    • e.g. postinst, Dockerfile etc.
    • see full list
  3. Skips scanning certain directories (case sensitive)
    • e.g. .git, .idea, .gradle etc.
    • see full list
  4. Skips scanning certain directories with specific peer files (case sensitive)
    • e.g. skip build sub-directory when build.gradle exists in the same directory etc.
    • see full list