A fast, highly scalable file system search tool for Linux, inspired by the "Everything" search engine for Windows. It features a client-server architecture with real-time file monitoring and heuristic fuzzy-search.
- Blazing Fast Search: In-memory indexing with Python-optimized search logic.
- Real-Time Monitoring:
- Recursive Inotify: Automatically tracks file creation, deletion, and movement in real-time.
- Robust Handling: Hand-tuned for deep directory structures and large trees.
- Client-Server Architecture:
- Server: Background daemon matching queries over Unix Domain Sockets.
- Client: Lightweight TUI (Text User Interface) with live search and debounce protection.
- Advanced Search Modes:
- All: Search everything (default).
- File: Search files only.
- Dir: Search directories only.
- Smart Scoring: Results are ranked by strictness and heuristic matching logic.
PySearch supports configuration files for customizing search paths and exclusions. Configuration files are loaded from multiple locations in order of precedence:
/etc/pysearch.conf(system-wide)~/.pysearchrc(user-specific)./pysearch.conf(project-specific)
CLI arguments are merged with configuration files.
Configuration files use INI format. You can generate a default configuration with:
pysearch default-config > ~/.pysearchrcExample configuration:
[search]
# Comma-separated list of directories to search
paths = /home, /opt
[exclude]
# Folder names to exclude from recursion (matches basename only)
folders = .git, .svn, .hg, CVS, .DS_Store, Thumbs.db, node_modules, __pycache__, .cache, .pytest_cache, .mypy_cache, .tox, .coverage, .vscode, .idea, .eclipse, .settings, target, build, dist, out, bin, obj, .gradle, .cargo, .rustup, .npm, .yarn, .pnpm, .venv, venv, env, .env, .terraform, .kube, .minikube, .docker, .vagrant
# Absolute paths to exclude entirely (no recursion)
absolute = /proc, /sys, /dev, /run, /boot, /tmp, /var/log, /var/cache, /var/tmp, /var/run, /lost+found- Define directories to index in the
[search]section - Multiple paths can be specified, separated by commas
- CLI
--dirarguments are added to configured paths - If no paths are configured and no CLI args, defaults to current directory
- folders: Matches directory basenames (e.g.,
.gitexcludes any folder named.git) - absolute: Matches exact absolute paths (e.g.,
/procexcludes/procand all subdirectories) - Excluded directories are still indexed as entries, but their contents are not scanned
- This prevents indexing unnecessary or problematic directories
pip install pysearch- Linux
- Python 3.10+
- Python dependency
prompt_toolkit
The server indexes the filesystem and listens for queries.
# Start in background (recommended to pipe log to file or /dev/null)
# Replace '.' with the path you want to index (e.g., ~ or /)
pysearch server --dir . You can configure search paths and exclusions using configuration files (see Configuration section above).
pysearch clientThe true power of this tool comes from integrating it with your shell environment. After installing PySearch, run one of the following commands and append the output to your shell configuration file.
pysearch bashrc-completions >> ~/.bashrc
source ~/.bashrcpysearch zshrc-completions >> ~/.zshrc
source ~/.zshrc| Command | Function | Description |
|---|---|---|
loc |
pysearch client |
Search Everything. Find any file or folder. |
locf |
pysearch client file |
Find Files. Restricted to files only. |
locd |
pysearch client dir |
Find Directories. Restricted to folders. |
ccd |
cd $(locd) |
"Cool CD". Fuzzy search a directory and cd into it instantly. |
ced |
$EDITOR $(locf) |
"Cool Edit". Fuzzy search a file and open it in your editor (vim, nano, code). |
cdh |
cd $(pysearch-cd-nav) |
"Cool Directory History". Fuzzy search and navigate to recently visited directories. |
If the server crashes with OSError: [Errno 28] No space left on device while using Inotify, it means you have exceeded the Linux kernel's maximum number of file watches.
To fix this, increase the limit:
# Temporary (until reboot)
sudo sysctl fs.inotify.max_user_watches=1048576
# Permanent
echo "fs.inotify.max_user_watches=1048576" | sudo tee -a /etc/sysctl.conf
sudo sysctl -pEnsure the server is running. The client communicates via a Unix socket at /tmp/pylocate_<UID>.sock.
- Shared Search Logic: Fuzzy matching and scoring is implemented in
search_util.pyfor reuse across scripts. - Protocol: Simple line-based text protocol (
SEARCH <MODE> <QUERY>) over UDS. - Debouncing: The client waits 150ms after user input before querying to prevent server overload.
- Scoring: Results include debug scores (e.g.,
[1050.0] /path/file); clients strip them for clean output.