minted environment with prefix

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.

• As this prefix would only be added to the first line: Do you want to only use one line of shell code (even if this might be set apart) in these environments? – TeXnician Apr 5 at 9:11
• @TeXnician Sometimes one line, sometimes more than one. The prefix should be in the same line as the beginning of the code... (It's not only for command line, it's also for REPL interaction -- when Python programmers test code in the REPL, it usually is multiline... The same for Lisps and Prolog) – Jay Apr 5 at 9:34