I had some trouble setting up minted
with pygments on Windows, but now it seems to run. So, this is my first minted
text - so, please, forgive me, if I'm doing some nonsense here. Nevertheless, I have found something which may be a ground to build on. The following code uses not exactly your syntax, but creates a myshellbox
instead.
Basically, I use the listings
features of tcolorbox
and trick minted
in at some point:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{minted}
\makeatletter
\tcbset{minted language/.store in=\kvtcb@minted@language}
\def\tcbuselistinglisting{%
\toks@=\expandafter{\kvtcb@listingoptions}%
\edef\tcb@temp{\noexpand\inputminted[\the\toks@]}%
\tcb@temp{\kvtcb@minted@language}{\kvtcb@listingfile}%
}%
\makeatother
\begin{document}
\section{Test}
\newtcblisting[auto counter,number within=section,
list inside=mypyg]{myshellbox}[2][]{%
title={Listing \thetcbcounter: #2},
list entry={\protect\numberline{\thetcbcounter}#2},
minted language=shell-session,
listing options={tabsize=2,fontsize=\footnotesize},
listing only,
enhanced,colframe=red!50!black,drop fuzzy shadow,
#1}
\begin{myshellbox}{Load network configuration with vi}
[root@localhost ~]# vi /etc/sysconfig/network
\end{myshellbox}
\begin{myshellbox}{Something else}
[root@localhost ~]# vi /etc/sysconfig/something
\end{myshellbox}
\tcblistof{mypyg}{My Listings}
\end{document}

EDIT: It should me mentioned that the created myshellbox
environment takes an optional parameter, where further options can be put in, e.g. minted language=<something>
or listing option=<something>
.
EDIT: The second solution is a combination of my first solution with Marco Daniel's answer:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{minted}
\newminted[mycsharp]{csharp}{tabsize=2,fontsize=\footnotesize}
\newminted[myjson]{js}{tabsize=2,fontsize=\footnotesize}
\newminted[myxml]{xml}{tabsize=2,fontsize=\footnotesize}
\newminted[myshell]{shell-session}{tabsize=2,fontsize=\footnotesize}
\newminted[mycode]{text}{tabsize=2,fontsize=\footnotesize}
\newtcolorbox[auto counter,number within=section,
list inside=mypyg]{mintedbox}[2][]{%
title={Listing \thetcbcounter: #2},
list entry={\protect\numberline{\thetcbcounter}#2},
enhanced,colframe=red!50!black,drop fuzzy shadow,#1}
\newenvironment{listingsbox}[3][]
{%
\def\listingsboxenvironment{#2}%save the environments
\VerbatimEnvironment%
\begin{mintedbox}[#1]{#3}%
\begin{\listingsboxenvironment}}%
{%
\end{\listingsboxenvironment}%
\end{mintedbox}%
}
\begin{document}
\section{Test}
\begin{listingsbox}{myshell}{A nice title}
[root@localhost ~]# vi /etc/sysconfig/network
\end{listingsbox}
\begin{listingsbox}{myshell}{Something else}
[root@localhost ~]# vi /etc/sysconfig/something
\end{listingsbox}
\begin{listingsbox}{myxml}{XML box}
<hello>World</hello>
\end{listingsbox}
\tcblistof{mypyg}{My Listings}
\end{document}

Update: Newer versions of tcolorbox
have integrated support for minted
. Therefore, a more elegant solution with the same output is possible now. I also added a macro \mynewminted
which creates a style for tcolorbox
plus an equally named minted
environment, if this is needed somewhere else.
\documentclass{article}
\usepackage[many,minted]{tcolorbox}% version 3.03 or better
\newcommand{\mynewminted}[3]{%
\newminted[#1]{#2}{#3}%
\tcbset{myminted/#1/.style={minted language=#2,minted options={#3}}}}
\mynewminted{mycsharp}{csharp}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myjson}{js}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myxml}{xml}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myshell}{shell-session}{tabsize=2,fontsize=\footnotesize}
\mynewminted{mycode}{text}{tabsize=2,fontsize=\footnotesize}
\newtcblisting[auto counter,number within=section,
list inside=mypyg]{listingsbox}[3][]{%
listing only,title={Listing \thetcbcounter: #3},
list entry={\protect\numberline{\thetcbcounter}#3},
enhanced,colframe=red!50!black,drop fuzzy shadow,myminted/#2,#1}
\begin{document}
\section{Test}
\begin{listingsbox}{myshell}{A nice title}
[root@localhost ~]# vi /etc/sysconfig/network
\end{listingsbox}
\begin{listingsbox}{myshell}{Something else}
[root@localhost ~]# vi /etc/sysconfig/something
\end{listingsbox}
\begin{listingsbox}{myxml}{XML box}
<hello>World</hello>
\end{listingsbox}
\tcblistof{mypyg}{My Listings}
\end{document}