term
A Rust library for terminfo parsing and portable terminal colors and formatting.
Repository Health
Technical Analysis
term is a Rust library for terminfo parsing and terminal formatting. It lets you set foreground and background colors, apply text attributes such as bold and underline, reset styling, and control the cursor in a way that works across a wide range of terminals.
Originally part of the Rust standard distribution and now maintained by Steven Allen, term reads the system terminfo database on Unix-like systems to emit the correct escape sequences for whatever terminal the program is running in, and uses the Windows Console API on Windows. This portability makes it a long-standing, heavily depended-upon building block for colored command-line output in the Rust ecosystem.
What You Get
- A terminfo parser that reads the system terminal capability database
- APIs to set foreground/background colors and text attributes (bold, underline, etc.)
- Cross-platform terminal handling with a Windows Console backend
Terminalabstractions over stdout/stderr for writing styled output
Common Use Cases
- Adding portable colored output to a Rust command-line application
- Emitting the correct escape sequences for the user’s actual terminal via terminfo
- Writing colored diagnostics that also work on Windows consoles
Under The Hood
Architecture — The crate is organized around src/lib.rs, a terminfo module that parses the compiled terminfo database and looks up capability strings, and src/win.rs, which implements the same Terminal interface against the Windows Console API. At runtime on Unix it resolves the terminal type (via TERM/TERMINFO), loads the matching terminfo entry, and emits the parameterized escape sequences it defines for colors, attributes, and cursor control.
Tech Stack — Pure Rust targeting edition 2021 with an MSRV of 1.63. It has essentially no dependencies on Unix and uses windows-sys (Win32 Console features) only on Windows. Distribution notes call out the runtime dependency on a system terminfo database (e.g. ncurses-term).
Code Quality — A mature, stable codebase descended from the Rust standard distribution, with CI (GitHub Actions) and a focused set of tests. Development is now infrequent, reflecting a feature-complete library rather than neglect.
API Design — The public API is small and approachable: obtain a Terminal over stdout/stderr and call methods to set colors, apply/reset attributes, and move the cursor. Because it mirrors terminfo semantics, behavior is predictable and portable without exposing low-level escape-sequence details to callers.