Skip to content

Terminal utilities reference


remove_ansi

remove_ansi(text: str) -> str

This strips out ANSI escape sequences from the given text.

Note

Not every sequence is supported.

terminal_size

terminal_size() -> terminal_size

This returns the same value as get_terminal_size but the first call is cached.

get_terminal_size

get_terminal_size(
    fallback: tuple[int, int] = (80, 24),
) -> terminal_size

This is a copy of the shutil.get_terminal_size function from the standard library. This is required to properly configure the CLI at startup but importing shutil is costly.