termenv is a library for adding colour, text formatting and terminal control functions to command-line applications. It detects the capabilities of the terminal and adapts output to the available colour range, reducing the need for applications to construct ANSI escape sequences or implement colour conversion themselves. Developers can use the library to build interfaces that work across terminals with different levels of support for advanced rendering and control sequences.
The library extends beyond text styling to provide cursor movement, screen management, mouse tracking and other terminal operations. It can query foreground and background colours, determine whether the terminal uses a light or dark theme, and select a suitable colour profile automatically or manually. Its output abstraction allows terminal commands to be directed to a particular stream, while helpers for Go templates make it possible to incorporate styled content into formatted output. Some operations, including clipboard access and notifications, depend on support from the receiving terminal.
This is free and open source software.
Key Features
- Support standard 16-colour ANSI, 256-colour and 24-bit TrueColor output.
- Automatically detect supported terminal colour profiles.
- Convert colours to the closest available match when a terminal supports a smaller colour range.
- Allow applications to select a specific colour profile instead of relying on automatic detection.
- Accept hexadecimal colour values, indexed ANSI colours and Go colour values.
- Query terminal foreground and background colours and detect light or dark themes.
- Combine foreground colours, background colours and text attributes using chainable styles.
- Support bold, faint, italic, underline, overline, blinking, reverse and crossed-out text.
- Provide helper functions for styling content in Go templates.
- Move the cursor, save and restore its position, and change cursor visibility.
- Clear terminal lines, modify scrolling regions, and insert or delete lines.
- Switch between the primary and alternate terminal screens.
- Enable and disable bracketed paste and several mouse tracking modes.
- Change terminal window titles and default foreground, background and cursor colours.
- Copy text to the system or primary clipboard through supported terminal control sequences.
- Generate terminal notifications and OSC 8 hyperlinks where supported.
- Respect the NO_COLOR and CLICOLOR_FORCE environment variables.
- Enable ANSI virtual terminal processing on Windows.
- Cross-platform support – runs on Linux, macOS, and Windows.
Website: github.com/muesli/termenv
Support:
Developer: Christian Muehlhaeuser
License: MIT License

termenv is written in Go. Learn Go with our recommended free books and free tutorials.
Related Software
| Terminal String Styling Libraries | |
|---|---|
| color | Go package for adding colour to terminal output |
| termenv | Advanced ANSI styling and terminal rendering for Go |
| owo_colors | Zero-allocation terminal colour library for Rust |
| Ansis | Small, fast library for styling terminal text |
| anstyle | Rust libraries for ANSI text styling |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.