# A package for formatting Linux terminal excerpts?

I know about minted and listings, but either of those are intended for formatting of programming languages excerpts. Is there a package that would do the same for Linux terminal excerpts?

Such as:

peter@kbpet:~$echo$(uname -i)
x86_64


The minimal solution would be to automatically embolden the peter@kbpet: to every line and indent the leading line of each block.

The other major convenience sought is math symbols like $ and _ should be automatically interpreted as escaped. - What kind of extra formatting are you looking for? My terminal output is just fixed-width text. I know some programs can output colours but this is not based on syntactic information so highlighting it will be difficult (e.g., ls colouring certain file types or permissions). – Pieter Sep 25 '11 at 9:55 @Pieter: The minimal solution would be to embolden the $bob@system: prelude to every terminal line and indent the leading line of each block. – ptrcao Sep 25 '11 at 9:59
Both packages support bash as language. So you should this give a try. – Thorsten Donig Sep 25 '11 at 10:01

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstdefinestyle{Bash}
{language=bash,
keywordstyle=\color{blue},
basicstyle=\ttfamily,
morekeywords={peter@kbpet},
alsoletter={:~$}, morekeywords=[2]{peter@kbpet:}, keywordstyle=[2]{\color{red}}, literate={\$}{{\textcolor{red}{\$}}}1 {:}{{\textcolor{red}{:}}}1 {~}{{\textcolor{red}{\textasciitilde}}}1, } \begin{document} \begin{lstlisting}[style=Bash] peter@kbpet:~$ echo \$(uname -i)
x86_64

\end{lstlisting}
\end{document}


-
On the right track. Can the peter@kbpet: be emboldened, and can output be a different colour, indented, or otherwise set apart from the user's input? – ptrcao Sep 25 '11 at 11:39
@ptrcao: Sorry but I don't know what you mean. – Marco Daniel Sep 25 '11 at 11:50
@ptrcao: I edited my post. What do you think? – Marco Daniel Sep 25 '11 at 12:18
Yep, getting real close. The last request is that the terminal output, in this case x86_64 be indented. The difficulty is that there is no intelligent way to program a macro that will distinguish output lines from commands. It seems it has to be manually done at this stage, which makes it impractical as all the possible commands and outputs will be prolific and inexhaustible. If anyone is smart enough to conceive of a macro that could distinguish terminal output from commands intelligently by getting feedback from the the OS itself, that would make my day. For now, answer accepted. – ptrcao Sep 26 '11 at 13:18
This can be done by 'write18' – Marco Daniel Sep 26 '11 at 14:10