Is it possible to understand why, and fix the faulty highlighting (inconsistent bold of only a few) in the listlistings for bash? The default rendering is worse than random. There is no reason why cd is bold and rm is not.

enter image description here

 basicstyle=\normalsize, language=Bash, showstringspaces=false, label={bashge2}, breaklines, caption=demo.sh
sudo ./compromise.sh # install a compromised tcc
cd /tmp
rm -rf tcctmp
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Thruston
    Oct 30, 2022 at 17:07
  • 1
    I agree that it looks poor, but technically I think sudo and rm are separate programs and not bash commands, which is why I guess the bash language definition leaves them out. You can see what is included in the docs here: ctan.org/pkg/listings, and it is really easy to add your own.
    – Thruston
    Oct 30, 2022 at 17:13

1 Answer 1


This is one way to improve it -- add some missing keywords, use some colour, and put it all in mono font.

morekeywords={rm, sudo}
sudo ./compromise.sh # install a compromised tcc
cd /tmp
rm -rf tcctmp

which should produce something like this:

enter image description here

The optional argument I have added to my suggested shell environment allows you to put the caption and label in like this:

\begin{shell}[caption=demo.sh, label={bashge2}]
sudo ./compromise.sh # install a compromised tcc
cd /tmp
rm -rf tcctmp

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .