termenv – Go library for safely adding colour

termenv is a Go library for safely adding colour and styling to terminal output. It detects the terminal’s capabilities and selects compatible ANSI colours and control sequences, avoiding the need to handle escape sequences and colour conversions directly.

The library supports applications running across terminals with different colour capabilities, automatically converting colours to the closest available alternative.

This is free and open source software.

Key Features

  • Supports 16-colour ANSI, 256-colour and 24-bit TrueColor output.
  • Automatically detects the terminal’s supported colour profile.
  • Converts colours to the closest match supported by the terminal.
  • Detects light and dark terminal themes.
  • Provides a chainable syntax for combining colours and text styles.
  • Supports bold, faint, italic, underline, overline, blinking, reverse and crossed-out text.
  • Allows styles to be nested.
  • Provides styling helpers for Go templates.
  • Offers cursor positioning, screen management and scrolling controls.
  • Supports alternate screens, bracketed paste and mouse tracking.
  • Can set terminal colours, window titles and cursor visibility.
  • Respects the NO_COLOR and CLICOLOR_FORCE environment variables.

Website: github.com/muesli/termenv
Support:
Developer: Christian Muehlhaeuser
License: MIT License

termenv

termenv is written in Go. Learn Go with our recommended free books and free tutorials.


Related Software

Terminal String Styling Libraries
colorGo package for adding colour to terminal output
termenvAdvanced ANSI styling and terminal rendering for Go
owo_colors Zero-allocation terminal colour library for Rust
AnsisSmall, fast library for styling terminal text
anstyleRust libraries for ANSI text styling

Read our verdict in the software roundup.


Best Free and Open Source Software 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.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted