ratatree
A file and directory picker widget for ratatui.
Drop it into any ratatui app. Your users get a full-featured file browser with keyboard navigation, fuzzy search, multi-select, and two view modes - all from a single widget.
┌─────────────────────────────────────────┐
│ ~/projects/ratatree/src │
│─────────────────────────────────────────│
│ 📁 view/ │
│ ▸ 📄 lib.rs │
│ ✓ 📄 state.rs │
│ 🔗 config -> ../config │
│─────────────────────────────────────────│
│ 1 selected | . hidden | / search │
└─────────────────────────────────────────┘
Quick Start
Add to your Cargo.toml:
[]
= { = "https://github.com/namil-k/ratatree.git" }
Three things to know:
FilePickerStateholds all the state (current directory, cursor, selections)FilePickerrenders it (implements ratatui'sStatefulWidget)PickerResulttells you what the user did (still browsing, picked files, or cancelled)
use ;
// Create the picker
let mut state = builder
.start_dir
.mode // files and directories
.build;
// In your event loop:
loop
Features
- List and Tree views - toggle with
Tab - Vim keybindings -
hjkl,gg,G,Ctrl+D/U(arrow keys too) - Fuzzy search - press
/and start typing - Multi-select -
Spaceto toggle,Enterto confirm - Hidden files - toggle with
. - Symlink support - follows symlinks with circular reference detection
- Filter callback - show only the files you want
- Themeable - customize every color via
FilePickerTheme
Builder Options
let mut state = builder
.start_dir // starting directory (default: ".")
.mode // FilesOnly | DirsOnly | Both
.view // List | Tree (default: List)
.show_hidden // show dotfiles (default: false)
.filter
.theme // custom FilePickerTheme
.build;
Key Bindings
Navigation
| Key | Action |
|---|---|
j / Down |
Move cursor down |
k / Up |
Move cursor up |
l / Right |
Enter directory |
h / Left / Backspace |
Go to parent directory |
gg |
Jump to top |
G |
Jump to bottom |
Ctrl+D |
Half page down |
Ctrl+U |
Half page up |
~ |
Go to home directory |
Actions
| Key | Action |
|---|---|
Enter |
Confirm selection (or enter directory) |
Space |
Toggle multi-select on current item |
Esc / q |
Cancel |
Tab |
Switch between List and Tree view |
. |
Toggle hidden files |
/ |
Start fuzzy search |
Search Mode
| Key | Action |
|---|---|
| Type | Filter entries in real time |
Enter |
Accept filter, return to normal mode |
Esc |
Clear filter, return to normal mode |
j/k / Up/Down |
Navigate within results |
Theming
Every visual element is customizable:
use FilePickerTheme;
use ;
let theme = FilePickerTheme ;
let mut state = builder
.theme
.build;
Integration with Your App
A common pattern is to show the picker as a modal overlay:
Running the Example
License
MIT