compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Don't print Ansi escape sequences if NO_COLOR set or TERM=dumb

Open mbucc opened this issue 2 years ago • 2 comments

Quick Summary: Well-behaved Unix programs won't print Ansi escape sequences if TERM=dumb

SSCCE

% set|egrep 'NO_COLOR|TERM='
NO_COLOR=1
TERM=dumb
% elm
Hi, thank you for trying out [92mElm[0m [92m0.19.1[0m. I hope you like it!
...
  • Elm: 0.19.1
  • Browser: N/A
  • Operating System: MacOS Ventura 13.1

Additional Details

As the other poster said, export TERM=dumb is the universal way of saying that your terminal is not capable of vt100 (and other, more exotic) sequences supported by xterm and the like. https://www.reddit.com/r/plan9/comments/iz9rdw/acme_on_linux_remove_ansi_in_win/

Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color. https://no-color.org

mbucc avatar Feb 20 '23 01:02 mbucc

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

github-actions[bot] avatar Feb 20 '23 01:02 github-actions[bot]

Workaround: elm 2>&1|perl -pe 's/\x1b\[[0-9;]*[mG]//g'

mbucc avatar Feb 20 '23 01:02 mbucc