Problem description
For a tutorial on interactive Unix shell usage, I am using \usepackage{listings} with the breaklines=true option to automatically break long shell commands across multiple lines.
On an interactive shell, line breaks are inserted into commands by terminating the line with \ and hitting <RETURN>, e.g.:
ls \ <RETURN>
-l
To illustrate this with the listings package, I would like to configure its prebreak option sich as to terminate long lines with \, followed by the \return macro from the menukeys package (which draws a symbol for the return key).
However, although I can get the prebreak option to work with other symbols (e.g., \leftarrow), using \return breaks compilation. How can I get it to work?
Mimimal working example (MWE)
\documentclass{article}
\usepackage{menukeys}% Provides \return (return key symbol)
\usepackage{listings}%
\lstdefinestyle{shell}{
breaklines=true,%
%
% Backslash only works, but I want to append \return from \usepackage{menukeys} to it
prebreak=\char`\\,%
%
% This works, but uses the wrong symbol.
%prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\leftarrow}},
% Source:
% http://www.bollchen.de/blog/2011/04/good-looking-line-breaks-with-the-listings-package/
%
% TODO: Various strategies for using \return all break compilation
%prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\return}},%
%prebreak=\raisebox{0ex}[0ex][0ex]{\return},%
%prebreak={\return},%
}
\begin{document}
\begin{lstlisting}[style=shell]
sleep 1; sleep 2; sleep 3; sleep 4; sleep 5; sleep 6; sleep 7; sleep 8; sleep 9; sleep 10
\end{lstlisting}
\end{document}

mwe.texand compiled it successfully viapdflatex mwe(Debian, TeXLive 2016) – Florian H. Mar 04 '17 at 17:02\sbox\RET{\return}to\sbox\RET{\ \return}, since adding the space to theprebreakoption broke compilation. – Florian H. Mar 04 '17 at 17:04