Skip to content

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.25
  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 or scfind --help shows this help message:

scfind is a 'find' command for source code files

Usage: 
	scfind [options] $DIRECTORY_PATH

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

Options:
	-h, --help        print help and exit
	-g, --git-aware   respect .gitignore (requires git on PATH)

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

Examples

scfind ~/Programming
scfind . | xargs grep --color "LinkedHashSet"
# Respect .gitignore (and nested repos' gitignores)
scfind -g ~/Programming
scfind --git-aware .

How to build?

go build && go test ./...

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 subdirectory when build.gradle exists in the same directory etc.
    • see full list

Optionally, with -g / --git-aware, when git is available and the search root (or a nested subdirectory) is a Git working tree, scfind also respects .gitignore (via git ls-files). Without that flag, Git is not consulted at all. If the flag is set but git is not on $PATH, scfind warns and falls back to the filesystem filters above.

About

'find' command for source code files

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages