リストを使用してbashをフォーマットする

リストを使用してbashをフォーマットする

私は Linux Bash とシェル スクリプトに関するドキュメントを LaTeX で書いています。そして、いくつか問題があります:

  • 行の先頭から書式設定を開始するにはどうすればよいですか?
  • 2 つの記号が同じ行にある場合 (<> など) にのみ、2 つの記号の間をフォーマットするにはどうすればよいですか?
  • マイナス記号をスペースにフォーマットするにはどうすればいいですかまたは行の終わり(次の行ではない)?

ここに写真があります:

ここに画像の説明を入力してください

最小限の動作例のコードは次のとおりです。

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{listings}
\usepackage[dvipsnames]{xcolor}

\lstset{ %
    basicstyle=\ttfamily\footnotesize,
    commentstyle=\color{ForestGreen},
    frame=single,
    keywordstyle=\color{RoyalBlue},
    language=Bash,
    showstringspaces=false,
    %morekeywords={blue},
    morestring=[s][\color{Gray}]{<}{>},
    morestring=[s][\color{OrangeRed}]{\ -}{\ },
    morestring=[s][\color{OrangeRed}]{*}{\ },
    morestring=[s][\color{OrangeRed}]{|}{\ },
    morestring=[s][\color{OrangeRed}]{\&}{\ },
}

\begin{document}

Every time:
\begin{enumerate}
    \item the first string in a line: blue
    \item after a minus \enquote{-} (including itself), which followed a space, the string gets: red
    \item special signs \enquote{* | \&}: red
    \item after a hash \enquote{\#} (including itself): the complete line green
    \item between less/greater than \enquote{<>} (including itself): gray
    \item if a string starts with a slash \enquote{/}: this string black
    \item the rest: black
\end{enumerate}

\begin{lstlisting}
blue -red text
blue -red text  # green ...
blue-blue <gray>
blue * black    # green ...
blue -red <gray>
# green ...
/black/black/ blue -red 
blue -red /black/black/
blue -red black-black
blue black > black
blue black < black
blue -red && black -red <gray> || black -red
/black/black/ blue
\end{lstlisting}

\end{document}

関連情報