Tag Info

New answers tagged


If your system has access to NodeJS you could install the following Node package, strip-ansi. $ npm install -g strip-ansi You can then run your command like so: $ command-that-produces-colored-output | strip-ansi > outfile


This script seems to be the one that produced the picture.


Git uses isatty() to check whether stdout is a tty: this is used to see if a pager must be used (pager.c) as well as colors (color.c).


Running: git diff --color=always > output shows the color escapes. Damn I found it in git's color.c file: static int check_auto_color(void) { if (color_stdout_is_tty < 0) ...


less can support colour with -r --raw-control-chars and -R --RAW-CONTROL-CHARS You could use Pythons pygmentize to do the highlighting and pipe it in. To combine it all configure a less filter as described on superuser


Those colors are determined by terminal control codes. For a near-complete reference have a look at the XTerm Control Sequences, most terminal emulators nowadays are mostly compatible to XTerm.


This is a color definition: Foreground \[\033[1;30m\] Background \[\033[44;1;31m\] Cheers,

Top 50 recent answers are included