wijjit.terminal.ansi.colorize

wijjit.terminal.ansi.colorize(text, color=None, bg_color=None, bold=False, underline=False)[source]

Apply ANSI colors and styles to text.

Respects NO_COLOR environment variable (https://no-color.org/). If NO_COLOR is set, returns text without any ANSI codes.

Parameters:
  • text (str) – Text to colorize

  • color (str, optional) – Foreground color code

  • bg_color (str, optional) – Background color code

  • bold (bool) – Apply bold style

  • underline (bool) – Apply underline style

Returns:

Text with ANSI styling applied (or plain text if NO_COLOR is set)

Return type:

str

Notes

Respects the NO_COLOR configuration and environment variable standard. See https://no-color.org/ for details.