I would like to create a new environment using minted, inside which there is always a prefix string.
For example, following this answer I have tried
\documentclass{article}
\usepackage{minted}
\newenvironment{cmdline}
{\VerbatimEnvironment
\begin{minted}{Bash}
user@host$ }
{\end{minted}}
\begin{document}
\begin{cmdline}
print('abc')
\end{cmdline}
\end{document}
But LaTeX will not compile it:
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
! FancyVerb Error:
Extraneous input ` user@host $ ' between \begin{cmdline}[<key=value>] and line e
nd
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}
l.14 \begin{cmdline}
If I remove the prefix user@host $, it works fine.
What did I do wrong? Is there a way to do what I'm trying to do?
edit: even if I decide to work on a single-line command, the best I could get was this:
\documentclass{article}
\usepackage{minted}
\newcommand{\cmdline}[1]{\mint{text}^user@host$ #1^}
\begin{document}
\cmdline{echo "hello world!" # saying hello...}
\end{document}
but then, the hash sign (#) gets duplicated in the output:
(Something to do with the hash from newcommand's argument, maybe? minted saw and reprodueced it?
edit, again:
I am now verifying if I can use inline Lua code to get this working.
