[Tex/LaTex] Warnings and errors highlighting when compiling in Bash environment

colorerrorshighlightingsyntaxwarnings

I'm processing a large document, using Latexmk in a Bash environment. It would be very helpful if error and warning messages were somehow highlighted or coloured, in order to facilitate spotting them. Specially when dealing with Biber and Biblatex, catching the warnings on time is important, as they won't normally stop the compilation process when something comes out.

Until recently, I was using the LateX bundle in TextMate, which helped showing only the most important messages (errors, warnings, inputs, includes, etc.) See here:

TextMate compiling

But I became deceptioned by that bundle and now I am compiling everything directly in the shell (Bash in Linux or Os X), as it gives me better control.

(Of course I could open the .log file, and configure the editor to search for/highlight these items, but I was thinking of "in the fly" highlighting/colouring.)

Is it possible to colour-code the stdout of latexmk (or in general of the *Tex bins)?

Best Answer

You can always pipe the output through something that does colour, one simple example produces

enter image description here

From running the command

  pdflatex tb67 2>&1 | grep --color=auto  "LaTeX Warning"

on a file with a ref{jjj} undefined reference which I inserted for demonstration purposes.