How can I highlight XML on the command line?
How can I highlight XML from stdin (e.g. piped from xmllint --format
) to stdout?
I know how to get highlighting working in nano
and view
, but is there something that just outputs to stdout and exits?
What I'd link to do is just type something like
xmllint --format xmlfile.xml | some-highlighter
or maybe, for big files
xmllint --format xmlfile.xml | some-highlighter | less
and get pretty output.
Supercat and grcat (grc) can do piped syntax highlighting. You'll probably have to make or find configuration files for XML. They are both available in the Ubuntu repositories as well as at the links provided.
Pygmentize has XML highlighting included. It's available as "python-pygments" in the Ubuntu repositories or by using easy_install Pygments
.
xmllint --format xmlfile.xml | pygmentize -l xml | less
This is how you do it using GNU source-highlight and less:
source-highlight -i /tmp/foo.xml -f esc | less -r