pfetch-rs icon indicating copy to clipboard operation
pfetch-rs copied to clipboard

Do not emit color or line wrapping controls when stdout is not a terminal

Open jwodder opened this issue 1 year ago • 1 comments

When pfetch is invoked in an environment in which stdout is not a terminal (e.g., when piping the program's output to another program), then color sequences should not be emitted (unless some explicit "force color" option is given), and the crossterm sequences for disabling & enabling line wrapping should not be emitted either.

FYI, you can test whether stdout is a terminal using the std::io::IsTerminal trait introduced in Rust 1.70.

jwodder avatar Jul 24 '24 14:07 jwodder

then color sequences should not be emitted (unless some explicit "force color" option is given)

PF_COLOR=1 might be a good option for that.

Gobidev avatar Jul 25 '24 12:07 Gobidev