\ProvidesPackage{code} \usepackage{tcolorbox} \usepackage{url} \usepackage{tikz} \usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing} \tikzset{every picture/.style={remember picture}} \tcbuselibrary{skins,xparse,listings} % Props to https://tex.stackexchange.com/questions/517976/drawing-realistic-linux-command-shell-windows-with-tcolorbox \tcbset{common/.style={ colback=violet!50!black, colupper=white, colframe=gray!65!black, listing only, listing options={ style=tcblatex, language=sh,escapeinside=``, }, every listing line={\MyMainPrompt}, }} \newtcblisting{shell}[1][]{ common, title={\textcolor{orange}{\Large{$\bullet$}}{\textcolor{gray}{\Large{$\bullet\bullet$}}}}, codewidth, fontsize, #1 } \newtcblisting{shellcomp}[1][]{ common, codewidth, fontsize, #1 } \tcbset{ codewidth/.style={width=#1\textwidth}, codewidth/.default=1, fontsize/.style={% listing options={ % TODO add only relevant stuff here (do not overwrite unrelated default) style=tcblatex, language=sh,escapeinside=``, basicstyle=\ttfamily#1, }, }, % fontsize/.default=\normalsize, } % \BeforeBeginEnvironment{shell}{\centering} \pgfkeys{/shell/.cd, user/.code={\gdef\MyMainUser{#1}}, user={}, host/.code={\gdef\MyMainHost{#1}}, host={}, color/.code={\gdef\MyMainColor{#1}}, color=white, pwd/.code={\gdef\MyMainPwd{#1}}, pwd=\~, prompt char/.code={\gdef\MyMainPromptChar{#1}}, prompt char=\#, root/.style={user=root,host=ubuntu,color=lime,pwd=/,prompt char=\#}, bob/.style={user=bob,host=ubuntu,color=cyan,pwd=\~,prompt char=\$}, bobremote/.style={user=bob,host=myRemote,color=green,pwd=\~,prompt char=>}, alice/.style={user=alice,host=arch,color=green,pwd=\~,prompt char=>}, } \newcommand{\SU}[1]{ \pgfkeys{/shell/.cd,#1}% \gdef\MyMainPrompt{\textcolor{\MyMainColor}{\MyMainUser @\MyMainHost{\textcolor{white}:}\textcolor{cyan!60}{\url{\MyMainPwd}}{\textcolor{white}\MyMainPromptChar} }} } \newcommand{\StartConsole}{\gdef\MyMainPrompt{}}