A small readline-style C library for command-line line editing, history, completion, and hints, used in Redis, MongoDB, Android, and other projects.
Overview
Linenoise is a minimal line-editing library intended as a lightweight alternative to readline and libedit. It is BSD-licensed and designed to embed in command-line utilities that need interactive input with history, without pulling in very large dependencies.
It supports single-line and multi-line editing modes with common key bindings, history handling, tab completion, inline hints, multiplexing with prompt hide and restore, bracketed paste with folded display for long input, and UTF-8 for multi-byte characters. The implementation spans roughly sixteen hundred lines of code using a subset of VT100 escapes compatible with ANSI.SYS.
The library offers a blocking API and an asynchronous multiplexing API for programs that also read sockets or other events. Mask mode can hide typed characters for secrets. History can be persisted to a file. Authors report testing on Linux consoles and terminals, macOS Terminal and iTerm, OpenBSD, IBM AIX, FreeBSD, ANSI.SYS, and Emacs comint mode.
It aims to stay a small, self-contained alternative to readline and libedit.
Key features
- Line editing with history
- Tab completion
- Inline hints
- Multi-line editing mode
- Bracketed paste support
- UTF-8 input
- Blocking and async APIs
- Password mask mode
Use cases
- CLI REPL interfaces
- Embedded shell clients
- Small utility line input
- Redis-style CLI tools
- Terminal programs without readline