# Typeset colored terminal output using minted

I need to reproduce the output of a command in a LaTeX document. The command uses ANSI escape codes to produce colored output.

I'd like to use minted, but using \inputminted{shell}{coloredoutput} produces the following error:

! Text line contains an invalid character.
l.2 ^^[
\PY{o}{[}01\PY{p}{;}31m^^[\PY{o}{[}Kt^^[\PY{o}{[}m^^[\PY{o}{[}K^^[\PY...


To reproduce, create colored output by running

grep --color=always . <(echo test) > coloredoutput


and then compiling the following MWE:

\documentclass{article}
\usepackage{minted}

\begin{document}
\inputminted{shell}{coloredoutput}
\end{document}


You will need -shell-escape.

The error, I imagine, is due to pygments not properly parsing the color codes. How do I force make it parse them properly?

Unfortunately, this is not possible. Currently, Pygments (which minted uses internally) performs all coloring based on styles, not based on color information passed to it. There has been a feature request for something like this since 2012, but it doesn't appear that any progress has been made.