fsearch README

The project's README from github.com/noahdunnagan/fsearch. As one markdown file: README.md.

FSearch

Whole-disk file search for macOS: names in about 0.1 ms, typo-tolerant, plus indexed search inside files. A CLI with a small daemon, a Rust crate, or an MCP server for coding agents.

cargo build --release && ./target/release/fsearch install   # -> ~/.local/bin/fsearch
fsearch fsearch main              # find files by name
fsearch 'ext:rs grep:apply_dir'   # search inside files

Or skip the Rust toolchain with a release build for Apple Silicon:

curl -L https://github.com/noahdunnagan/fsearch/releases/latest/download/fsearch-aarch64-apple-darwin.tar.gz | tar xz && ./fsearch install

Speed

M4 Mac mini, a home holding the Linux or the Chromium source tree, vs the previous version (b88f4e9). Medians; Linux / Chromium.

before now
right file first, name search 83% / 86% 93% / 97%
right file first, two typos 11% / 15% 74% / 93%
find a file by name 0.045 / 0.10 ms 0.054 / 0.12 ms
an edited file greppable 2.1 s 1.3 ms
a rename or delete visible 45 / 47 ms 18 / 15 ms
first run, a name in a folder 7.8 / 7.8 s 0.18 / 1.2 s
first run, every match in the tree 10.9 / 12.2 s 2.4 / 10.8 s
files grep can search (rg's own set) 96% / 92% 99.9% / 99.8%
grep, first page 0.29 / 0.48 ms 0.33 / 0.65 ms
index on disk 503 / 893 MB 309 / 600 MB
peak memory while indexing 1.13 / 1.37 GB 0.77 / 0.94 GB
daemon memory 19 / 100 MB 21 / 35 MB

The index is a third smaller while holding a third more text: one 3-bit filter per file instead of two, compressed posting lists and paths, and bit-packed name arrays read in place. Grep's first page reads a few more files for it, and the deeper typo search costs a little on names.

Queries

fsearch 'readme in:~/Developer'          # inside a folder
fsearch 'type:image size:>5mb mtime:<7d'
fsearch 'ext:rs regex:fn\s+\w+_dir'      # regex inside files
fsearch 'sym:apply_dir'                  # where it's defined
fsearch 'src/**/*.{c,h} !test/ init'     # globs, in or out
fsearch 'git:modified in:~/Developer/app'

Words are fuzzy and forgive a typo at any letter, two in words of 8+ (mian.rs finds main.rs); several words can spell one name. Accented names match however they were stored. Also 'exact, ^prefix, suffix$ and !exclude. Filters: ext: type: kind: in: size: mtime: re: path: grep: regex: sym: limit: and git: (modified staged untracked clean tracked ignored conflict). Content search is smart-case, and regexes match within a line, as in ripgrep.

What grep covers

Text files up to 1 MB, and up to 10 MB inside git repos, minus what git ignores. It leaves out lockfiles, JSON of 100 KB and up, minified or bundled assets, linked git worktrees (their main checkout is indexed), and build-output folders outside repos. To leave out more, list folders in ~/Library/Application Support/FSearch/content-skip.txt, one per line (~ and # comments work). Names are always indexed, and a grep inside a file you name still reads it.

Churn folders — caches, logs, build output, node_modules, folders with a CACHEDIR.TAG — are indexed like everything else, but their changes show up only once they quiet down (a few seconds; a minute at most under churn that never stops).

Full Disk Access

From a terminal with Full Disk Access it indexes everything. As a login item (fsearch install --login), grant ~/.local/bin/fsearch access in System Settings > Privacy & Security, again after each rebuild. Without access it skips protected folders instead of prompting.

API

JSON lines over ~/Library/Application Support/FSearch/fsearch.sock, or fsearch stdio:

{"q": "fsearch main", "limit": 20, "offset": 20}
{"op": "grep", "pattern": "apply_dir", "in": "~/Developer", "context": 2}
{"q": "main.rs", "boost": true, "near": "~/Developer/app/src/lib.rs", "git": true}
{"op": "open", "path": "~/Developer/app/src/main.rs"}
{"op": "recent", "in": "~/Developer/app"}

open tells it what you opened; "boost": true ranks those higher for a while, near favors files close to the one you're in, and recent lists what you worked on lately. "git": true adds each hit's git status.

For coding agents, fsearch mcp is an MCP server on stdio with find_files, grep and multi_grep.

Or link the crate:

let engine = fsearch::Engine::start(fsearch::Options { dir: fsearch::default_dir(&home), home: home.clone(), skip: None })?;
let hits = engine.search(&fsearch::Query::parse("fsearch main", &home)?)?;

An app and the CLI share one index: the first process owns it, the rest follow.

How it works

fsearch (noahdunnagan/fsearch)

Searching Database…

What is this?FSearch is a whole-disk file search tool for macOS that finds any file by name in about a millisecond, tolerates typos, and can search inside file contents using an index.
Is this a CLI tool or a Rust library?Both: it ships as a CLI backed by a small background daemon, and the same functionality can be linked into your own project as a Rust crate.
How do I get it running?Run it from a terminal with Full Disk Access granted so it can crawl the whole disk, and optionally register it as a login item with fsearch install --login so it starts automatically.
Do I need to grant Full Disk Access first?For full coverage yes - FSearch needs Full Disk Access in System Settings, and that grant has to be redone after each rebuild of the binary.
What happens if I don't grant Full Disk Access?It won't nag you with a permission prompt - it just silently skips the protected folders it can't see while still indexing everything else.
Does it run on Linux too, or is it macOS-only?It's built specifically for macOS: it relies on getattrlistbulk and FSEvents for crawling and live updates, and permissions go through macOS System Settings.
Does my data leave the machine?No - everything runs locally: a background daemon crawls the disk once and keeps an index on-device, with content matches read fresh from local disk rather than stored or sent anywhere.
How does fsearch compare to a tool like fff?On a 509k-file test, fsearch finds files by name in 1.1ms vs 13.8ms for fff, searches contents in 5.6ms vs 53ms, and uses 50MB of memory for the whole disk vs 358MB for fff on just one folder.
What query syntax does it support?Queries are fuzzy by default (words of 5+ letters forgive one typo), and you can use 'exact, ^prefix, suffix$ and !exclude, plus filters like ext:, type:, kind:, in:, size:, mtime:, re:, path:, grep:, regex:, sym: and limit:.
How does it stay up to date as files change?It crawls the whole disk once at startup with getattrlistbulk, then keeps itself current by watching FSEvents, so new, renamed, or deleted files show up in about 0.1 seconds; a restart only replays what changed since.
Can an app and the CLI share the same search index?Yes - FSearch exposes JSON lines over a Unix socket at ~/Library/Application Support/FSearch/fsearch.sock (or via stdio), and the first process to start owns the index while any others just follow along.
What are similar projects?ripgrep, memex, xerj, fff, meilisearch, leviathan, sonic, tantivy
Size
3.4 MB
Stars
2.2K
Age
1mo
Commits · 90 Days