Noureddine RAMDI / leaf: a Rust terminal Markdown previewer with GUI-like interactivity

Created Mon, 04 May 2026 10:23:01 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

RivoLink/leaf

leaf is a terminal-based Markdown previewer written in Rust that aims to deliver a GUI-like experience directly inside your terminal. It supports live preview with automatic reload on file changes, fuzzy file selection, syntax highlighting, LaTeX formula rendering, and YAML frontmatter display. The design embraces CLI workflows, particularly for users piping AI-generated Markdown output directly into the viewer for instant feedback without leaving the terminal.

What leaf is and how it works

leaf is built as a terminal user interface (TUI) application leveraging Rust’s ecosystem for performant and safe code. It focuses on rendering Markdown documents within a terminal window but with features you typically expect from graphical applications.

Key features include live preview with file watching, so edits to the Markdown file trigger an immediate refresh. It offers fuzzy file picking for opening documents, making navigation fast without needing to leave the terminal or resort to external tools. Syntax highlighting covers common programming languages embedded in code blocks, enhancing readability.

Under the hood, leaf uses a TUI framework to draw an interactive interface comprising a main preview pane, a table of contents sidebar, and a theme picker. It supports mouse and keyboard inputs, which is notable in terminal apps where mouse support is often limited or absent.

The Markdown rendering supports advanced elements like LaTeX formulas, which are rendered inline, and YAML frontmatter display, useful for metadata inspection. This makes leaf particularly suited for academic notes, technical documentation, or AI-generated content where such features are common.

Distribution-wise, leaf provides multiple installation methods: a curl-based shell script installer for macOS, Linux, Android, and Termux environments; a PowerShell script for Windows; npm package distribution; and packaging in the Arch User Repository (AUR). This multi-platform approach covers a broad developer audience.

Technical strengths and tradeoffs in leaf’s implementation

leaf’s primary technical strength is how it achieves a rich, GUI-like experience within the constraints of a terminal environment. Many Markdown previewers either spin up a browser window or require complex GUI dependencies. leaf avoids this by fully embracing a TUI approach, which reduces resource footprint and fits naturally into CLI-heavy workflows.

The live file watching is implemented efficiently to trigger automatic reloads without noticeable lag. This is important for smooth editing experiences. The fuzzy file picker is implemented with performance and UX in mind, letting users quickly locate files without typing full paths.

Rendering LaTeX formulas inside a terminal is not trivial, and leaf does this in a way that looks clean and integrates with the rest of the Markdown content. This feature distinguishes it from many other terminal Markdown tools that either ignore formulas or require external rendering steps.

The self-update mechanism with SHA256 checksum verification is a solid addition, ensuring users can keep their installation secure and up to date without manual intervention. This is especially useful since binaries are distributed directly via scripts.

Tradeoffs include the inherent limitations of terminal rendering—complex layouts or very large documents can be challenging to display gracefully. The TUI approach also means users accustomed to graphical apps might miss some interactive niceties or plugins available in GUI Markdown editors.

The codebase benefits from Rust’s safety guarantees and modern concurrency primitives, which helps maintain responsiveness and stability. However, being a Rust project, extending or customizing leaf might require familiarity with Rust and TUI paradigms, which can be a barrier for some users.

Install and get started with leaf

Install the latest published binary.

macOS / Linux / Android / Termux:

curl -fsSL https://raw.githubusercontent.com/RivoLink/leaf/main/scripts/install.sh | sh

Windows:

irm https://raw.githubusercontent.com/RivoLink/leaf/main/scripts/install.ps1 | iex

npm:

npm install -g @rivolink/leaf

ArchLinux (AUR):

Use an AUR helper, such as yay:

yay -S leaf-markdown-viewer

Verify the installation:

leaf --version

Once installed, you can open a Markdown file with leaf yourfile.md or simply pipe Markdown content into leaf for instant preview. The interface supports mouse interaction, theme switching, and table of contents navigation, making it easy to browse and read Markdown documents efficiently.

Who should consider leaf

leaf is a solid choice for developers and writers who prefer working in the terminal and want a Markdown previewer that doesn’t pull them out into a separate GUI window. Its live reload and LaTeX support make it particularly appealing for technical documentation, academic writing, or AI-generated Markdown workflows.

The project strikes a reasonable balance between features and simplicity while avoiding heavy dependencies. However, users who rely heavily on graphical features, plugins, or WYSIWYG editing might find leaf’s terminal-bound interface limiting.

Also, while Rust underpins a robust codebase, the project doesn’t currently offer plugin extensibility or integrations beyond core features, so advanced customization requires diving into the Rust source.

Overall, leaf caters well to CLI enthusiasts and those who want to keep their writing and preview tightly integrated in the terminal. It’s a good example of how terminal apps can deliver surprisingly rich user experiences with careful design and modern Rust tooling.


→ GitHub Repo: RivoLink/leaf ⭐ 498 · Rust