Hacker News new | ask | show | jobs
by Beltalowda 1250 days ago
That's kind of what aliases are for.
1 comments

That's exactly the poor programming I was referring to.

Call isatty()!

The downside of that is that piping to less won't display colours any more either, so then you need "progname -color=always" or some such. Some programs solve that with a built-in "pipe to terminal" feature, but I always find that a bit annoying.

I don't know anything about terraform, but I've written some applications where I intentionally don't automatically change the output (which in my case is usually bold text, I don't use colours much) because I expect no one will ever use the output for scripting . That's not "poor programming", it's a choice because there is no perfect solution that fits 100% of the cases.

I suspect that may probably be the best choice for terraform as well, but I never used it.

But piping to less would display the escape codes, not the colours anyway… which is why this is done.

Imagine grep not working because in between the words that you are searching there is an escape code.

That depends on the settings used for less; AFAIK the default for many distros is to display control characters.