\verbatiminput shell command Minted equivalent

mintedshell-escape

\verbatiminput{|"echo foo"}

produces foo, wrapped in verbatim.
Is it possible to do the same with Minted’s syntax highlighting?
I have tried

\begin{minted}[escapeinside=!]{text}
!\verbatiminput{|"echo foo"}!
\end{minted}

but it didn’t work.
I also tried

\inputminted{text}{|"echo foo"}

but it gave an error of

(./_minted-report/friendly.pygstyle)sh: line 1: echo foo: command not found

Best Answer

It would be \inputminted but unlike \verbatiminput or even listings, the filename has to be passed to other programs notably pygmentize so I suspect it would take a lot of work to make that all work with the fake pipe syntax.

What you can do is use \write18 to execute the command, saving to a temporary file, then use \inputminted on that, so for example:

\immediate\write18{echo foo > /tmp/cmd_out.txt}
\inputminted{text}{/tmp/cmd_out.txt}