cdepillabout/pretty-simple

pPretty detected tty for whether to enable color or not

juhp opened this issue · 2 comments

juhp commented

For example if one outputs to a pipe, file or Emacs shell-command etc, then the ANSI color control characters are visible , so it would be better to detect whether one is using a TTY terminal or not and depending on that decide whether to enable color or not in the default output.

One can do this by using say https://hackage.haskell.org/package/base-4.12.0.0/docs/System-IO.html#v:hIsTerminalDevice

This sounds like a good idea to me. I'd be willing to accept a PR implementing this.

It would also be nice to make it an option so the end user could configure this.

This shouldn't be too hard, so I'll mark it beginner friendly.

If nobody else feels like doing so, I will try doing this in the evening (GMT+2).

We should probably add functions that always print colored output, even outside TTYs, and also the tracing functions should somehow do the detection too, right?