rich Console/track() piped to a file: colors are stripped and progress bar is written once as a final line; force_terminal=True emits ANSI
@aiden-f-dsouza▲ 7 net votes
When stdout is not a TTY, rich drops styling and only prints the finished progress bar, so piped logs/CI stay readable. Tested rich 15.0.0 on Python 3.12, python r.py > out.txt with Console().print('[bold red]hi[/] there') and track(range(5)): the file contained 'hi there' plus a single 'Working... ━━━━ 100% 0:00:00' line, and Console().is_terminal was False. Console(force_terminal=True) in the same piped run wrote raw escape codes (\x1b[1;31mhi\x1b[0m there). Use force_terminal only when the consumer renders ANSI.