Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ecbb40d
docs: 修改帮助信息为英文,去掉类似 Everything
dacj4n Mar 17, 2026
1edb655
docs: 更新文档,去掉类似 Everything 的描述
dacj4n Mar 17, 2026
3638a6e
refactor: 将所有运行时输出改为英文
dacj4n Mar 17, 2026
915552c
refactor: 将数据库和日志路径改为 ~/.machunt/
dacj4n Mar 17, 2026
0e816a0
refactor: 修正目录结构,data 和 logs 为同级目录
dacj4n Mar 17, 2026
a276714
refactor: modularize core into engine/db/search/builder/watcher
dacj4n Mar 19, 2026
d08027c
chore: prepare workspace before new gui branch
dacj4n Mar 19, 2026
083d85c
feat: add tauri-react gui and refresh README with versioning
dacj4n Mar 20, 2026
809383b
chore: update gitignore for gui/build artifacts
dacj4n Mar 20, 2026
19e5896
merge: integrate gui branch
dacj4n Mar 20, 2026
c2b1eb9
feat(stage1): optimize indexing pipeline and shrink DB overhead
dacj4n Mar 20, 2026
fbb9f11
feat(gui): polish UX interactions and rewrite README docs
dacj4n Mar 20, 2026
0856ae4
fix(gui): disable auto-capitalize and spell suggestions in inputs
dacj4n Mar 21, 2026
8700725
feat(gui): persist search mode and case-sensitive toggles
dacj4n Mar 21, 2026
be65480
feat(gui): make regex an additive toggle over substring search
dacj4n Mar 21, 2026
95e63e4
feat(gui): add sortable type column and terminal open-with actions
dacj4n Mar 21, 2026
cbac9bf
chore(tauri): add bundle icon assets and config
dacj4n Mar 21, 2026
cd29557
feat(gui): improve selection and quick look interaction
dacj4n Mar 21, 2026
70c52ed
feat(gui): lock search and path inputs while index loads
dacj4n Mar 21, 2026
4c823f0
feat(gui): close-to-hide window and add configurable global shortcut
dacj4n Mar 21, 2026
a1b876a
feat(gui): hide app from Cmd+Tab when window is hidden
dacj4n Mar 21, 2026
f2b67b7
chore(icons): update tauri icon assets
dacj4n Mar 21, 2026
6956667
docs(ui): refresh readmes and clear selection on blank click
dacj4n Mar 21, 2026
20a223d
fix(ui): stabilize table widths and remove horizontal scrollbar
dacj4n Mar 23, 2026
13848be
fix(build): make clipboard copy reliable in bundled app
dacj4n Mar 26, 2026
cd0e5e1
chore(release): bump version to 0.2.1
dacj4n Mar 26, 2026
9fc2fa1
chore(release): sync Cargo.lock for 0.2.1
dacj4n Mar 26, 2026
3d96456
feat(settings): add launch-at-login and silent startup options
dacj4n Mar 26, 2026
57c7575
fix(settings): use macOS login items for launch-at-login
dacj4n Mar 26, 2026
b0617a4
fix(ui): apply dark theme styles for startup settings
dacj4n Mar 26, 2026
168159d
docs: update README and architecture notes for startup and clipboard
dacj4n Mar 26, 2026
ab52b9c
fix(mac): improve WezTerm open behavior and auto-focus terminal apps
dacj4n Mar 26, 2026
6111510
feat(startup): switch to ServiceManagement, add app silent startup, a…
dacj4n Mar 26, 2026
d3fe413
feat: replace qlmanage with native macOS Quick Look
dacj4n Mar 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/target
/src-tauri/target
/node_modules
/dist
/doc
/logs
/data
/node_modules/
/dist/
/src-tauri/target/
/src-tauri/gen/
.DS_Store
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "machunt"
version = "0.1.0"
version = "0.2.2"
edition = "2021"

[dependencies]
Expand Down
253 changes: 178 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,131 +1,234 @@
# MacHunt

macOS Global File Search Tool - Similar to Windows' Everything
A fully local macOS search tool for files and folders, with both CLI and native GUI (Tauri + React). No HTTP backend service is required.

[中文文档](README_zh.md)

## Features

- ⚡ **High Performance**: Search entire disk in seconds
- 🔍 **Real-time Monitoring**: Monitor file changes in real-time
- 📂 **Flexible Search**: Support substring, regex, folder/file filtering
- 🔄 **Incremental Indexing**: Fast rebuild with event ID persistence
- 🗄️ **Persistent Storage**: SQLite-based index storage

## Requirements
## Version

- GUI: `v1.1.0` (base release)
- CLI/Core: `v0.2.2` (base release)

## Latest Branch Updates (after v1.1.0)

- Window close behavior changed to **hide to background** (`Cmd+W` / red close button), while `Cmd+Q` still quits.
- Hidden window now switches to macOS accessory mode, so it does **not appear in Cmd+Tab**.
- Added configurable global shortcut to toggle window visibility.
- Showing window by shortcut auto-focuses the search input.
- Settings page now supports vertical scrolling.
- Clicking blank area in result list clears current selection.
- Clipboard copy in bundled builds is now hardened with multi-path fallback.
- Settings now include **Launch at Login** and **Silent Startup** options.
- Launch-at-login now integrates with macOS **Login Items** (not only background items).
- Startup settings card now has complete dark-theme styling.

## Core Capabilities

### CLI

- Build / rebuild local index
- Search by substring or wildcard pattern
- File-only / folder-only filtering
- Path-prefix filtering
- `watch` mode with FSEvents incremental updates
- `optimize --vacuum` for DB maintenance

### GUI

- Instant local search (no server)
- Regex toggle + case-sensitive toggle
- Path filter: manual input + suggestion dropdown + Finder picker
- Auto watcher start on app launch
- Build / rebuild controls
- Multi-tab category filter (all/files/folders/documents/images/media/code/archives)
- Click-to-sort on table headers (name/path/type/size/modified)
- Draggable column splitters with persisted widths
- Single/multi selection (`Shift` range, `Cmd` additive)
- Keyboard row navigation (`ArrowUp/ArrowDown`)
- Space-triggered Quick Look preview (multi-selection supported)
- Double-click to open files/folders
- Context menu actions:
- Open
- Open With... (Finder / QSpace Pro / Terminal / WezTerm)
- Copy name / path
- Copy all selected names / paths
- Move to Trash
- Theme settings (system/light/dark)
- Language settings (zh/en)
- Global shortcut settings for show/hide window
- Startup settings: launch at login + silent startup (applies to auto-launch only)

## Tech Stack

- Core: Rust
- CLI: Clap
- GUI frontend: React 18 + TypeScript + Vite
- GUI container: Tauri 2
- Global shortcut: `tauri-plugin-global-shortcut`
- Storage: SQLite (`rusqlite`, WAL mode)
- In-memory index: `DashMap<String, Vec<PathBuf>>`
- Scanner: WalkDir + Crossbeam channels
- Watcher: macOS FSEvents (CoreServices)

## Architecture Overview

- `src/`: shared core engine used by both CLI and GUI
- `src-tauri/`: Tauri backend commands and window/menu lifecycle
- `src/App.tsx`: GUI application logic and interactions

Detailed architecture and optimization notes:

- [doc/PROJECT_ARCHITECTURE_CN.md](doc/PROJECT_ARCHITECTURE_CN.md)

## Build and Run

### Requirements

- macOS 10.15+
- Rust 1.70+
- Node.js 18+
- npm 9+

## Installation
### Install

```bash
git clone https://github.com/dacj4n/MacHunt.git
cd MacHunt
cargo build --release
```

## Usage

### First-time Setup
### CLI

```bash
# Build file index (required before first use)
machunt build # Full disk scan, ~15-20 seconds

# Or build index for specific path
machunt build --path "/Volumes/Tools"
cargo build --release
./target/release/machunt --help
```

### Search
### GUI (dev)

```bash
# Search for files/folders containing "test"
machunt "test"
npm install
npm run tauri dev
```

# Search only files
machunt --file "test"
### GUI (package)

# Search only folders
machunt --folder "test"
```bash
npm run build
npm run tauri build
```

### Regex Search
## Build Command Difference

```bash
# Search all pdf files
machunt --regex "*.pdf"
### `npm run build`

# Search pdf and docx files
machunt --regex "*.{pdf,docx}"
- Only builds frontend assets (TypeScript + Vite)
- Outputs static files to `dist/`
- Does **not** compile Rust backend
- Does **not** produce `.app` / `.dmg`

# Search files with specific pattern
machunt --regex "*.mp{3,4}"
```
### `npm run tauri build`

- Builds the full desktop app package
- Runs `beforeBuildCommand` in `src-tauri/tauri.conf.json` first (currently `npm run build`)
- Compiles Rust code under `src-tauri/`
- Generates installable artifacts such as `.app` / `.dmg`

### Path Filtering
## App Icon Generation (Tauri)

Use the following command to generate multi-size app icons from a 1024x1024 source image:

```bash
# Search in specific directory
machunt --path "/Volumes/Tools" "test"
npm run tauri icon src-tauri/icons/app-icon-1024.png
```

### Real-time Monitoring
Notes:

```bash
# Start real-time monitoring (keep running in background)
machunt watch
- The source image should be square, preferably `1024x1024`.
- This command generates platform icon assets under `src-tauri/icons/`.
- After regeneration, `npm run tauri build` will bundle the updated icons automatically (as referenced by `src-tauri/tauri.conf.json`).

# Then search from anywhere
machunt "test"
```
## CLI Reference

## Permissions
Syntax:

**Important**: To monitor all directories, you need to grant Full Disk Access to your terminal:
```bash
machunt [OPTIONS] [QUERY] [COMMAND]
```

1. Go to **System Settings → Privacy & Security → Full Disk Access**
2. Click the lock icon and enter your password
3. Click **+** and add your terminal app (Terminal.app, iTerm2, etc.)
4. Restart your terminal
Top-level options:

Without this permission, monitoring will only work for `/Users` directory.
- `-p, --path <PATH>`: path prefix filter (`.` means none)
- `-r, --regex`: wildcard pattern mode
- `--folder`: folders only
- `--file`: files only
- `--logs`: write logs to `~/.machunt/logs`
- `[QUERY]`: search query when no subcommand is used

## Wildcard Rules
Selection rule:

- `*` - Match any characters (excluding `/`)
- `**` - Match any characters (including `/`)
- `?` - Match single character (excluding `/`)
- `{a,b}` - Match `a` or `b`
- no `--file` and no `--folder` => include both files and folders
- only `--file` => files only
- only `--folder` => folders only

## Examples
Subcommands:

### `build`

```bash
# Search for all video files
machunt --regex "*.{mp4,mov,avi}"
machunt build [OPTIONS]
```

# Search for large files
machunt --regex ".*\.pdf"
- `-p, --path <PATH>`: build only this scope
- `--rebuild`: clear old index first
- `--include-dirs <true|false>`: include directories (default `true`)

# Search for test files in specific path
machunt --path "/Volumes/工作" "测试"
### `watch`

# Monitor file changes
```bash
machunt watch
```

## Performance
- Starts FSEvents watcher
- Replays from last EventID when available
- Enters interactive search loop

### `optimize`

```bash
machunt optimize [--vacuum]
```

- Always runs WAL checkpoint
- Optional `--vacuum` to reclaim DB file space

- Index building: ~10-15 seconds for 2M files
- Search response: <50ms for typical queries
- Memory usage: ~200-300MB for 2M files
Wildcard rules (`--regex`):

## Architecture
- `*` => any chars except `/`
- `**` => any chars including `/`
- `?` => one char except `/`
- `{a,b}` => `a` or `b`

- **Index Storage**: SQLite database with WAL mode
- **File Monitoring**: FSEvents API for macOS
- **Concurrent Access**: DashMap for lock-free access
- **Parallel Processing**: Crossbeam for multi-threaded scanning
## Runtime Data

- DB: `~/.machunt/data/index.db`
- GUI settings: `~/.machunt/gui/settings.json` (shortcut + launch-at-login + silent-start)
- Logs: `~/.machunt/logs/`

## Why DB Can Be Large

Common reasons:

- Large file count (often millions)
- Directory indexing enabled by default
- Long path strings dominate storage
- `dirs + files` relational structure still stores large cardinality
- WAL files (`index.db-wal`) can temporarily become large during writes

Maintenance:

```bash
machunt optimize --vacuum
```

## License

Expand Down
Loading