:py:mod:`terminal` ================== .. py:module:: conda.common.terminal .. autoapi-nested-parse:: Utility functions for terminal output. Functions --------- .. autoapisummary:: conda.common.terminal._stream_is_tty conda.common.terminal.is_tty conda.common.terminal.is_stdin_tty conda.common.terminal.is_stderr_tty conda.common.terminal.is_interactive_tty conda.common.terminal.term_dumb conda.common.terminal.no_color conda.common.terminal.force_color conda.common.terminal.should_use_color .. py:function:: _stream_is_tty(stream) -> bool Return True if the given stream object is connected to a TTY. .. py:function:: is_tty() -> bool Return True if stdout is connected to a TTY. .. py:function:: is_stdin_tty() -> bool Return True if stdin is connected to a TTY. .. py:function:: is_stderr_tty() -> bool Return True if stderr is connected to a TTY. .. py:function:: is_interactive_tty() -> bool Return True if both stdout and stdin are connected to a TTY. Use this before showing an interactive prompt that reads from stdin, so the prompt is skipped (instead of hanging or erroring) when either stream has been redirected, e.g. ``some-command < /dev/null``. .. py:function:: term_dumb() -> bool Return True when ``TERM`` indicates a non-capable terminal. ``TERM=dumb`` is the widely-followed terminfo convention for terminals that cannot render any ANSI escape sequences (color, bold, animations). ``TERM=unknown`` is treated the same way as a defensive fallback. .. py:function:: no_color() -> bool Return True when *color* output should be suppressed. Respects the ``NO_COLOR`` standard (https://no-color.org/): color is suppressed when the ``NO_COLOR`` environment variable is set to any value. Non-color ANSI formatting (bold, underline, etc.) may still be used. .. py:function:: force_color() -> bool Return True when color output should be forced even in non-TTY contexts. Respects the ``FORCE_COLOR`` environment variable when it is set to a non-empty value. .. py:function:: should_use_color() -> bool Determine whether ANSI color output should be produced. The precedence order (highest to lowest) is: 1. ``NO_COLOR`` set -> no color. 2. non-empty ``FORCE_COLOR`` set -> color even in non-TTY. 3. ``TERM=dumb``/``TERM=unknown`` -> no color. 4. stdout is a TTY -> color. 5. Otherwise -> no color.