How to tell that stdout is a color terminal?

⚓ Rust    📅 2025-08-23    👤 surdeus    👁️ 6      

surdeus

I know that it's a color terminal and insert escape ANSI codes in my print out. However if I need to capture stdout some other app and redirect to my terminal, it will come in black and white. So, I use some special command flag to get a colorized out from the app. I looked at how to set stdout:

pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Command

I looked at StdoutStdout and didn't find how to tell it supports color. I know, there is Rust Shell, so I need just look in its code. But if someone can tell me without looking in its code, I appreciate the help.

2 posts - 2 participants

Read full topic

🏷️ Rust_feed