Rustyline
A readline/line-editing library for building interactive Rust REPLs and CLI shells
Repository Health
Technical Analysis
Rustyline is a Rust implementation of readline-style line editing, based on Antirez’s Linenoise, that gives command-line applications features like history, cursor movement, kill-ring cut/paste, tab completion, and syntax highlighting for interactive input. It’s the library most Rust REPLs and interactive shells reach for instead of hand-rolling terminal input handling.
The crate works cross-platform (Unix terminals and Windows console/PowerShell) and exposes an Editor type that applications configure with pluggable Completer, Highlighter, Hinter, and Validator traits, plus optional history persistence to a plain file or a SQLite-backed history store via the sqlite_history feature. A companion rustyline-derive crate provides derive macros for composing these traits onto a single custom helper type.
What You Get
- An
Editortype providing line editing with history, kill-ring cut/paste, and both emacs- and vi-style keybindings - Pluggable
Completer,Highlighter,Hinter, andValidatortraits for tab completion, syntax highlighting, inline hints, and multi-line input validation - Cross-platform terminal support for Unix (Linux, macOS, FreeBSD) and Windows (cmd.exe, PowerShell)
- History persistence to a plain text file by default, or to SQLite via the
with-sqlite-historyfeature - The
rustyline-derivecompanion crate for deriving the helper traits on a single custom type
Common Use Cases
- Building an interactive REPL for a programming language, database client, or scripting tool
- Adding tab-completion and command history to a custom interactive CLI shell
- Providing syntax-highlighted input for a domain-specific interactive query tool
- Persisting and recalling command history across sessions in a terminal application
Under The Hood
Architecture - The crate centers on edit.rs (the core line-editing state machine) and keymap.rs/command.rs (translating keypresses into editing commands under emacs or vi modes), backed by a tty module abstracting Unix termios and Windows console APIs behind a common interface. Extension points (completion.rs, highlight.rs, hint.rs, validate.rs) define traits that consuming applications implement to customize behavior, while history.rs/sqlite_history.rs handle persisting and recalling past input.
Tech Stack - Pure Rust (edition 2024) with platform-specific dependencies gated by cfg(unix)/cfg(windows) — nix for Unix terminal control, and Windows console APIs on that platform — plus unicode-width/unicode-segmentation for correct cursor movement over multi-byte and combining characters, and an optional rusqlite (bundled) dependency for SQLite-backed history. The workspace also includes rustyline-derive, a small proc-macro crate for deriving the helper traits.
Code Quality - Tests are organized in a dedicated src/test module covering emacs and vi keybinding behavior (emacs.rs, vi_cmd.rs, vi_insert.rs) plus history handling, with 22 files across the crate containing #[test] blocks — a meaningful investment in behavioral coverage for something as fiddly as terminal input handling. The deny.toml config and CI badge (maintenance = actively-developed) signal an active dependency-auditing and maintenance practice.
API Design - The DefaultEditor::new() entry point requires zero configuration for the common case, while power users compose custom completion/highlighting/hinting/validation behavior by implementing a handful of well-scoped traits on a single helper struct (optionally derived via rustyline-derive), keeping the common path simple without boxing out advanced customization.
Used by 4 apps in this directory
claw-code
AI Agents · AI Code Assistants
A Rust-built CLI agent harness for Claude AI with persistent sessions, MCP tool integration, plugin hooks, and multi-provider support — designed to run autonomous coding workflows without human babysitting.
mesh-llm
AI Development · AI Agents
Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.
monty
AI Development · Developer Tools
Run LLM-generated Python code safely inside your agent—no containers, no CPython, no compromise—with sub-microsecond startup.
OpenViking
Databases · AI Development
An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.