# listings: Highlight one-line delim without the delimiter itself

I would like to use a one-line delimiter (with [l] parameter), but without highlighting the delimiter itself; something like

sqlite> .open ex2.db

What follows sqlite> should get highlighted but not sqlite> itself. I found solutions only for multi-line delimiters. I'm not able to make them work for one-line delimiters:

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}
\usepackage{listings}
\usepackage{newtxtt}

\newcommand{\functionHighlightAfterSqlite}[1]{\ttfamily\bfseries\color{red}{#1}}

\lstnewenvironment{lstSqlite}
{\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
language=SQL,
moredelim=*[l][\functionHighlightAfterSqlite]{sqlite>},
moredelim=[l][\ttfamily\bfseries\color{red}]{...>}} } % highlights delimiter
{}

\begin{document}
\begin{lstSqlite}
sqlite> .open ex2.db
sqlite> select *
...> from tab;
Git|1
SQLite|3
\end{lstSqlite}
\end{document}


Same trick as described in this answer:

\documentclass[a4paper, 12pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}
\usepackage{listings}
\usepackage{newtxtt}

\newcommand\styleAfterSqlitePrompt{%
\ttfamily\bfseries\color{red}%
}

% switch to keep track of context (in a command or not)
\newif\ifcom\comfalse

\makeatletter

% This is what happens if a delimiter is encountered
\newcommand\processSqlitePrompt[1]{%
\ifcom%                       % In this case, we're already in a command.
\else                         % Otherwise, we just started a command;
\global\comtrue%          % set the switch to true and
{\lst@basicstyle #1}%     % typeset the delimiter in the basic style.
\fi
\styleAfterSqlitePrompt%      % In any case, apply the comment style.
}

% Reset the switch at each End-Of-Line character.

\makeatother

\lstnewenvironment{lstSqlite}{%
\lstset{
language     = SQL,
basicstyle   = \ttfamily,
keywordstyle = \bfseries,
moredelim    = *[il][\processSqlitePrompt{sqlite>}]{sqlite>},
moredelim    = *[il][\processSqlitePrompt{\ \ \ ...>}]{\ \ \ ...>},
}%
}{}

\begin{document}

\begin{lstSqlite}
sqlite> .open ex2.db
sqlite> select *
...> from tab;
Git|1
SQLite|3
\end{lstSqlite}

\end{document}

• Is there a way to turn on/off language settings. Like {\lst@basicstyle #1} – mwloda Dec 11 '15 at 12:09