3

I'm familiar with typesetting script code in my documents, however, I have been unable to obtain nice highlighting for shell code (e.g. similar to that afforded to me by my gnome-terminal).

Basically this is what I would like to get:

enter image description here

The best I can do with listings is the following code:

\definecolor{tlg}{gray}{0.9}
\lstset{frame=tb,
    backgroundcolor = \color{tlg},
    language=bash,
    aboveskip=3mm,
    belowskip=3mm,
    showstringspaces=false,
    columns=flexible,
    basicstyle={\footnotesize\ttfamily},
    numbers=none,
    rulecolor=\color{tlg},
    backgroundcolor=\color{tlg},
    fillcolor=\color{tlg},
    rulesepcolor=\color{tlg},
    numberstyle=\tiny\color{gray},
    keywordstyle=\color{blue},
    commentstyle=\color{dkgreen},
    stringstyle=\color{mauve},
    breaklines=true,
    breakatwhitespace=true,
    tabsize=3
}


\begin{lstlisting}
chymera@quiethost ~/myfolder $ ls -lh
total 0
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_final.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_final_version2.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:57 mytext.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_version2.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_version3.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_version4.txt

\end{lstlisting}

which produces:

enter image description here

And the best I can do with minted is the following code:

\begin{minted}{bash}
chymera@quiethost ~/myfolder $ ls -lh
total 0
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_final.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_final_version2.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:57 mytext.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_version2.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_version3.txt
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 mytext_version4.txt
\end{minted}

which produces

enter image description here

5

Using fancyvrb package

\documentclass[10pt,a4paper]{letter}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}
\usepackage{xcolor}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
\textcolor{green}{chymera@quiethost} \textcolor{blue!50}{~/myfolder $} ls -lh
total 0
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 \textcolor{green!50!black}{mytext_final.txt}
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 \textcolor{green!50!black}{mytext_final_version2.txt}
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:57 \textcolor{green!50!black}{mytext.txt}
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 \textcolor{green!50!black}{mytext_version2.txt}
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 \textcolor{green!50!black}{mytext_version3.txt}
-rw-r--r-- 1 chymera chymera 0  1. Mai 23:58 \textcolor{green!50!black}{mytext_version4.txt}
\end{Verbatim}
\end{document}

the result is

code highlighted

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.