What Are Fetchers?
Fetchers run in the background to collect file metadata without blocking the UI. Common uses:- MIME type detection - Identify file types
- Git status - Show version control info
- Image metadata - Extract dimensions, format, EXIF
- Audio tags - Read ID3 tags from music files
- Custom properties - Any file-specific data
Fetcher Structure
The Job Object
Example: MIME Type Fetcher
Yazi’s local MIME fetcher using thefile command:
yazi.toml:
Example: Directory MIME Fetcher
Mark directories with a special MIME type:Example: Remote MIME Fetcher
Detect MIME types for remote files:Example: Git Status Fetcher
Show Git status for files:Updating Metadata
Update MIME Types
Update Custom Metadata
Batch Processing
Process files efficiently in batches:Throttling Updates
Avoid overwhelming the UI:Streaming Output
Read command output line by line:Error Handling
Configuration
Configure fetchers inyazi.toml:
Priority Levels
high- Essential, run firstnormal- Standard prioritylow- Nice-to-have, run last
Best Practices
Process files in batches
Process files in batches
Call external tools once for multiple files:
Throttle UI updates
Throttle UI updates
Don’t emit events too frequently:
Handle missing tools gracefully
Handle missing tools gracefully
Set placeholder values when tools are unavailable:
Use timeouts for reads
Use timeouts for reads
Don’t block indefinitely:
Clean up child processes
Clean up child processes
Always kill spawned processes:
Next Steps
Previewers
Create custom file previewers
Functional Plugins
Add new commands