terminal#
Utility functions for terminal output.
Functions#
|
Return True if the given stream object is connected to a TTY. |
|
Return True if stdout is connected to a TTY. |
|
Return True if stdin is connected to a TTY. |
|
Return True if stderr is connected to a TTY. |
|
Return True if both stdout and stdin are connected to a TTY. |
|
Return True when |
|
Return True when color output should be suppressed. |
|
Return True when color output should be forced even in non-TTY contexts. |
|
Determine whether ANSI color output should be produced. |
- 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.
- term_dumb() bool#
Return True when
TERMindicates a non-capable terminal.TERM=dumbis the widely-followed terminfo convention for terminals that cannot render any ANSI escape sequences (color, bold, animations).TERM=unknownis treated the same way as a defensive fallback.
- no_color() bool#
Return True when color output should be suppressed.
Respects the
NO_COLORstandard (https://no-color.org/): color is suppressed when theNO_COLORenvironment variable is set to any value. Non-color ANSI formatting (bold, underline, etc.) may still be used.