Lightning-fast file searching with fuzzy matching, written in Zig
Features • Installation • Usage • Examples • Contributing
|
🚀 Blazing Fast
|
🎯 Smart Matching
|
|
🎨 Beautiful Output
|
⚙️ Highly Configurable
|
- Zig 0.14.0 or later
# Clone the repository
git clone https://github.com/Paol0B/zs.git
cd zs
# Build the release version
zig build -Doptimize=ReleaseFast
# The binary will be in zig-out/bin/zs# Linux/macOS
sudo cp zig-out/bin/zs /usr/local/bin/
# Or add to your PATH
export PATH="$PATH:$(pwd)/zig-out/bin"zs [options] <pattern>| Option | Description | Default |
|---|---|---|
-h, --help |
Show help message | - |
-p, --path <path> |
Starting directory | / |
-d, --depth <n> |
Maximum search depth | 10 |
-c, --case |
Enable case-sensitive search | off |
-l, --limit <n> |
Maximum results to display | 100 |
-n, --no-color |
Disable colored output | off |
# Find all files matching "main.zig"
zs main.zig
# Search in a specific directory
zs -p /home/user/projects config
# Limit search depth
zs -d 3 readme# Case-sensitive search for exact matches
zs -c MyImportantFile
# Show more results
zs -l 500 test
# Search without colors (for piping)
zs -n package | grep -i json
# Combine multiple options
zs -p /usr/local -d 5 -l 20 -c binaryThe output uses colors to help you quickly identify file types:
| Color | File Type | Example |
|---|---|---|
| 🔵 Blue | Directories | src/, config/ |
| 🟢 Green | Executables | zs, run.sh |
| 🔴 Red | Archives | .zip, .tar.gz |
| 🟣 Magenta | Images | .png, .jpg |
| 🔷 Cyan | Audio | .mp3, .wav |
| ⚪ White | Regular files | .txt, .md |
The search engine uses a sophisticated scoring system:
Base Score Calculation:
├─ Character match: +10 points
├─ Consecutive matches: +5, +10, +15... (progressive)
├─ Start of string bonus: +20 points
├─ After separator bonus: +15 points (/, _, -, .)
└─ Length penalty: -1 per extra character
- Recursive Traversal: Efficiently walks directory trees
- Dual Matching: Both fuzzy and substring matching
- Smart Scoring: Ranks results by relevance
- Thread-Safe: Concurrent directory scanning with mutex protection
Pattern: "conf"
Results:
1. config.toml (score: 95) ← exact prefix match
2. app.conf (score: 85) ← contains exact pattern
3. configuration.yml (score: 65) ← all chars match, longer name
4. src/config/ (score: 60) ← directory match|
🎯 Scope Your Search # Instead of searching everything
zs pattern
# Search specific directories
zs -p ~/projects pattern
zs -p /usr/local pattern |
📊 Limit Depth # Deep searches take longer
zs -d 20 pattern
# Shallow searches are faster
zs -d 3 pattern |
|
🔢 Control Results # Fewer results = faster display
zs -l 20 pattern
# More results = more processing
zs -l 1000 pattern |
🚫 Skip System Dirs # Avoid /proc, /sys, /dev
zs -p /home pattern
zs -p /opt pattern |
# Debug build (faster compilation)
zig build
# Run directly
zig build run -- -p . test
# Run tests
zig build test
# Release with debug info
zig build -Doptimize=ReleaseSafe
# Smallest binary
zig build -Doptimize=ReleaseSmallPerformance on a standard system (SSD, 16GB RAM):
| Directory | Files | Time | Results |
|---|---|---|---|
/home/user |
~50K | 0.8s | 145 matches |
/usr/local |
~20K | 0.3s | 67 matches |
| Small project | ~1K | 0.05s | 12 matches |
Note: Times may vary based on system specifications and disk I/O.
- Built with Zig - A general-purpose programming language
- Inspired by tools like
fd,fzf, andripgrep - Thanks to the open-source community