Colorization script
authorVivien Maisonneuve <v.maisonneuve@gmail.com>
Tue, 11 Feb 2014 09:45:45 +0000 (10:45 +0100)
committerVivien Maisonneuve <v.maisonneuve@gmail.com>
Tue, 11 Feb 2014 09:45:45 +0000 (10:45 +0100)
bin/latex-colorize [new file with mode: 0755]
latexmkrc

diff --git a/bin/latex-colorize b/bin/latex-colorize
new file mode 100755 (executable)
index 0000000..5a46c16
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+COLOR_ERROR='01;31'
+COLOR_WARNING='01;33'
+COLOR_OUTPUT='01;32'
+
+PCRE_ERROR='(^[^:]*:\d+: )|(^l\.\d+ )|(^! LaTeX Error: )'
+PCRE_WARNING='(LaTeX Warning(:|))|(Package [^\s]+ Warning(:|))'
+PCRE_OUTPUT='^Output written on .*\.pdf \(.*\)\.$'
+
+if [ -t 1 ]; then
+    ($* -file-line-error 2>&1) | perl -pe "s/${PCRE_ERROR}/\033[${COLOR_ERROR}m\$&\033[0m/gs;s/${PCRE_WARNING}/\033[${COLOR_WARNING}m\$&\033[0m/gs;s/${PCRE_OUTPUT}/\033[${COLOR_OUTPUT}m\$&\033[0m/gs"
+else
+    $*
+fi
index a973307..5a277e8 100644 (file)
--- a/latexmkrc
+++ b/latexmkrc
@@ -1,3 +1,4 @@
+$ENV{PATH} = "bin:$ENV{PATH}";
 $pdf_mode = "1";
 $pdf_mode = "1";
-$pdflatex = "pdflatex -interaction=nonstopmode -halt-on-error -file-line-error -synctex=1";
+$pdflatex = "latex-colorize pdflatex -interaction=nonstopmode -halt-on-error -file-line-error -synctex=1";
 $clean_ext = "bbl synctex.gz synctex.gz(busy)";
 $clean_ext = "bbl synctex.gz synctex.gz(busy)";