A Go library for advanced ANSI styling and color support in terminal applications with automatic terminal capability detection.
termenv is a Go library that provides safe and convenient access to advanced terminal styling features like colors, text styles, cursor positioning, and screen manipulation. It abstracts away the complexity of ANSI escape sequences and automatically adapts to the terminal's capabilities, making it easier to build rich, cross-platform command-line interfaces.
Go developers building command-line applications that require rich terminal output, such as TUIs (Terminal User Interfaces), CLI tools with colored or formatted text, and interactive terminal programs.
Developers choose termenv because it automatically detects terminal capabilities and gracefully degrades features, eliminating manual compatibility checks. Its chainable syntax and comprehensive feature set—including color conversion, template helpers, and mouse support—provide a unified API for advanced terminal operations across different platforms.
Advanced ANSI style & color support for your terminal applications
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically detects color profiles (TrueColor, ANSI256, ANSI, Ascii) and themes (light/dark), ensuring styles degrade gracefully without manual compatibility checks, as shown in the Terminal Detection and Color Conversion features.
Offers a chainable syntax for text styles, RGB color conversion, and template helpers, simplifying complex terminal output with methods like String().Bold().Underline() and template functions from the README.
Supports Unix and Windows systems, with built-in helpers like EnableVirtualTerminalProcessing for Windows to enable ANSI processing, making it suitable for diverse environments as detailed in the Platform Support section.
Includes cursor positioning, screen manipulation, mouse event handling, and session controls like clipboard operations and notifications, providing a unified API for rich CLI applications beyond basic styling.
Requires explicit code to enable virtual terminal processing on Windows, adding setup complexity compared to Unix systems where ANSI is native, as admitted in the Platform Support section.
The compatibility matrix reveals gaps in feature support; for example, Konsole lacks cursor color setting, and some terminals do not support OSC52 for clipboard operations, which can limit functionality in certain environments.
For applications needing only basic text output, the library's abstraction layer and dependency might introduce unnecessary complexity compared to using standard Go packages like fmt.