Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Please don't.

Or rather, please think about whether adding rich text to your command line application actually makes it more useful before you do this.

One great benefit of command line applications on Unix is that they can be composed in pipelines. There is a convention that everything is just text. Escape codes throw a wrench in this. And once you start changing your output based on whether you're writing to a tty or a pipe, you run the risk of surprising users with divergent behavior.

More selfishly, not everyone is using a conventional terminal. Your app might get called from a text editor or IDE which doesn't support escape codes. Or a simplified, pure-text interface like 9term.



Most better terminal programs detect if they are writing to a pipe and disable the ansi support.

Some CI tools seem to mess this up somehow, but “why not both” is an option.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: