colored-rs / colored

(Rust) Coloring terminal so simple you already know how to do it !
Mozilla Public License 2.0
1.68k stars 82 forks source link

No colors with less -r #128

Open pronebird opened 1 year ago

pronebird commented 1 year ago

Does not seem to produce colored output when using with | less -r or | grep. Not sure what changed. Used cli_tables before and everything seemed to work fine.

hwittenborn commented 1 year ago

Hey! I'm a new contributor to this project, but I'll be helping to keep things going forward for the crate.

I'm pretty sure this is due to here:

https://github.com/colored-rs/colored/blob/73b7106ac8e7d6e4dd3e6e74dc25ce255faabc52/src/control.rs#L108

Which disables coloring when you're not using a TTY (which I'm pretty sure is the case when you're piping out to another program). I'm still figuring out if this is supposed to be intended behavior, but I'll let you know once I figured out otherwise. In the meantime you can still set the CLICOLOR_FORCE variable to force color to be enabled though.