tty

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package tty provides terminal detection and colour helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Colourise

func Colourise(text, code string) string

Colourise wraps text in the given ANSI escape code when colour is enabled, and returns the plain text otherwise. code should be an SGR parameter string such as "92" (bright green) or "91" (bright red).

func IsColourEnabled

func IsColourEnabled() bool

IsColourEnabled reports whether ANSI colour output should be produced.

Colour is disabled when any of the following conditions is true:

  • The NO_COLOR environment variable is non-empty (https://no-color.org)
  • The TERM environment variable is "dumb"
  • stdout is not a character device (i.e. it is a pipe or regular file)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL