Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
130 changes: 130 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ log = "0.4.31"
miette = {version = "7.6.0", features = ["fancy"]}
mq-lang = "0.6.1"
mq-markdown = "0.6.1"
notify-debouncer-mini = "0.7.0"
ratatui = "0.30.0"
unicode-width = "0.2.2"

Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Interactive terminal interface for querying and manipulating Markdown content

- 🔍 **Interactive Query Mode** - Real-time Markdown querying with instant results
- 🌳 **Tree View** - Visual exploration of Markdown document structure
- 👀 **Rendered Preview** - View Markdown rendered close to its final look, right in the terminal
- 📺 **Watch Mode** - Automatically reload files when they change on disk
- 📑 **Multi-file Tabs** - Open several Markdown files at once and switch between them
- ⚡ **Vim-style Navigation** - Efficient keyboard shortcuts (j/k, hjkl)
- 📋 **Clipboard Integration** - Copy results directly to clipboard
- 🎨 **Syntax Highlighting** - Color-coded display of different Markdown elements
Expand Down Expand Up @@ -87,6 +90,30 @@ all tabs: whatever query you run is applied to every open file at once, so
switching tabs shows that file's own filtered results without retyping the
query. Press `o` at any time to open another file as a new tab.

### Watch Mode

Pass `--watch` (or `-w`) to automatically reload files when they change on disk:

```bash
mq-tui --watch README.md
```

The status line shows a `👀 watching` indicator while watch mode is active.
Each open file is watched using your OS's native file system notifications
(inotify on Linux, FSEvents on macOS, ReadDirectoryChangesW on Windows) -
no polling involved, so changes are picked up almost instantly. When a file
is modified externally (e.g. saved from your editor, including atomic
save-and-rename), its content is reloaded and the current query is re-run
automatically. Watch mode is not available when reading from stdin.

### Rendered Preview

Press `p` to switch to a rendered preview of the active document - headings,
bold/italic text, lists, blockquotes, code blocks, tables, and links are
styled to look close to their final rendered form instead of raw Markdown
syntax. Use `↑`/`k`, `↓`/`j`, `PageUp`/`PageDown`, or `g`/`G` to scroll, and
press `p` or `Esc` to return to normal mode.

### Query Examples

Once in the TUI, press `:` to enter query mode and try these queries:
Expand Down Expand Up @@ -121,6 +148,7 @@ Once in the TUI, press `:` to enter query mode and try these queries:
| `:` | Enter query mode |
| `?` / `F1` | Show help screen |
| `t` | Toggle tree view mode |
| `p` | Toggle rendered preview mode |
| `d` | Toggle detail view for selected item |
| `y` | Copy results to clipboard |
| `Ctrl+L` | Clear current query |
Expand Down Expand Up @@ -171,6 +199,19 @@ Once in the TUI, press `:` to enter query mode and try these queries:
| `Home` / `End` | Jump to start/end of path |
| `Backspace` / `Delete` | Edit path text |

### Preview Mode

| Key | Action |
| --------------- | ----------------------------- |
| `↑` / `k` | Scroll up |
| `↓` / `j` | Scroll down |
| `PageUp` | Scroll up (10 lines) |
| `PageDown` | Scroll down (10 lines) |
| `g` | Jump to top |
| `G` | Jump to bottom |
| `←` / `→` | Switch tabs (when multiple files are open) |
| `Esc` / `p` | Exit preview |

## Modes

### Normal Mode
Expand All @@ -185,6 +226,10 @@ Activated by pressing `:`. Type your mq query and press Enter to execute. The qu

Activated by pressing `t`. Displays the Markdown document structure as an expandable tree, showing the hierarchy of headings, lists, and other elements.

### Preview Mode

Activated by pressing `p`. Renders the active document's Markdown source close to its final look - styled headings, emphasis, lists, blockquotes, code blocks, tables, and links - instead of raw Markdown syntax.

### Help Mode

Activated by pressing `?` or `F1`. Displays all available keyboard shortcuts and commands.
Expand Down Expand Up @@ -218,6 +263,13 @@ The tree view mode provides a visual representation of your Markdown document's
- 🟡 **Yellow**: Images
- 🔵 **Cyan**: Code blocks

### Watch Mode

Run with `--watch` to keep open files in sync with disk. This is handy when
editing a Markdown file in another editor while exploring it with `mq-tui` -
save your changes and they show up immediately, with the current query
re-applied to the updated content.

## Configuration

`mq-tui` works out of the box with sensible defaults. The UI adapts to your terminal's color scheme and size.
Expand Down
Binary file modified assets/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 63 additions & 3 deletions assets/demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ Type "clear"
Enter
Show

Type `mq-tui demo.md`
# Open two Markdown files as tabs
Type `mq-tui demo.md demo2.md`
Enter
Sleep 1.5s

# Switch tabs
Tab
Sleep 1s
Tab
Sleep 1s

# Sidebar navigation
Type `s`
Sleep 1s

Expand All @@ -42,23 +50,75 @@ Sleep 1s
Type `s`
Sleep 1s

# Query mode
Type `:`
Sleep 0.5s

Type `.h`
Sleep 1.5s

Backspace 2
Sleep 1.5s
Sleep 1s

Type `.code`
Sleep 1.5s

Backspace 5
Sleep 1.5s
Sleep 1s

Type `select(.code.lang == "python")`
Sleep 1.5s

Escape
Sleep 1s

# Rendered preview mode
Type `p`
Sleep 1.5s

Type `j`
Sleep 0.4s

Type `j`
Sleep 0.4s

Type `j`
Sleep 0.4s

Type `j`
Sleep 0.4s

Type `j`
Sleep 1.5s

Escape
Sleep 1s

Type `q`
Sleep 0.5s

# --watch: auto-reload when the file changes on disk
Hide
Type `cp demo.md /tmp/mq-tui-watch-demo.md`
Enter
Type `clear`
Enter
Show

Type `(sleep 3 && printf '\n## Live Reload\n\nThis section was appended on disk while mq-tui was watching.\n' >> /tmp/mq-tui-watch-demo.md) & disown`
Enter
Sleep 0.5s

Type `mq-tui --watch /tmp/mq-tui-watch-demo.md`
Enter
Sleep 4s

Type `G`
Sleep 2s

Type `q`
Sleep 0.5s

Hide
Type `rm -f /tmp/mq-tui-watch-demo.md`
Enter
Loading