2

I want to make appear "adriano@ubuntu:~$" in blue but I cannot figure out why this doesn't work. I modified the example from here.

Here is my mwe:

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset{ 
  backgroundcolor=\color{gray!10},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
  basicstyle=\footnotesize,        % the size of the fonts that are used for the code
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % sets automatic line breaking
  captionpos=b,                    % sets the caption-position to bottom
  commentstyle=\color{green},    % comment style
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  keepspaces=false,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  keywordstyle=\color{blue},       % keyword style
  language=bash,                 % the language of the code
  morekeywords={adriano@ubuntu:~},            % if you want to add more keywords to the set
  numbersep=5pt,                   % how far the line-numbers are from the code
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % underline spaces within strings only
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=2,                    % the step between two line-numbers. If it's 1, each line will be numbered
  stringstyle=\color{red},     % string literal style
  tabsize=2,                     % sets default tabsize to 2 spaces
  title=\lstname                   % show the filename of files included with \lstinputlisting; also try caption instead of title
}
\begin{document}
  \begin{lstlisting}[language=bash, title=Example]       
    adriano@ubuntu:~$ openssl req -newkey rsa:2048 -nodes -keyout dnsdist.key -x509 -days 365 -out dnsdist.pem #test
  \end{lstlisting}
\end{document} 

Which give me the result :Result Btw, I would also add the numerotation for my code, for example, instead of just example, display Code x.x example (like for the section).

Thx for the help,

1 Answer 1

3

Instead of morekeywords use otherkeywords:

otherkeywords={adriano@ubuntu:~}

enter image description here

1
  • Thanks, I will read the difference between these two instructions :)
    – Warok
    Dec 17, 2018 at 14:46

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.