Since I can't use the listings packet to display my bash script (because of the wrong syntax highlighting by using i.e. language=bash) I have to use the minted package. So I have two questions:

Does anyone know, if it's possible to correctly syntax highlight a bash script with listings (with \lstdefinelanguage{bash}{...} or something like this)?

This is how it looks like with

\lstset{language=bash,caption={some text above},label=remote_command_execution}

enter image description here

=> wrong syntax highlighting

I know, that its possible with the minted package. But first: I don't like the font (it's some curlicue font which doesn't look that good for showing some program code) and second: I don't now how to put my code into a "box". With "a box" I mean this here: enter image description here

So the best solution for me would be a correct syntax highlighting for my bash script with listings. Otherwise minted with a better font and "a box".

  • Would be nice to know what exactly you expect to be different. Like coloured variables before the '=' in device=$1 etc. Could you give a coloured example using \textcolor{<color>}{<colored text>}? or some explanation? – franziska Mar 22 '17 at 9:50
  • For example, when you use in Linux vi or nano to view your code, you get a correct highlighting (or with any other program, such like sublime or notepad++). Like this: linux.x10host.com/blog/wp-content/uploads/2015/10/… I'm not dealing with the colors itselfs - i.e. its not important, if the $ is blue or green or whatever. The whole structure should have a correct syntax highlighting, unattached of the colors itselfs. – idontknowwhoiamgodhelpme Mar 22 '17 at 15:15
  • I see. In this answer it is explained that shell is a problem with listings so perhaps you can change to minted and use tcolorbox or something like that for the box. – franziska Mar 22 '17 at 16:25
  • Yeah. Minted wouldn't be a problem at all, but you can see my "font problem" perfectly in this answer. Good font: i.stack.imgur.com/bgczV.png // bad minted font: i.stack.imgur.com/plJFk.png . Can i change the minted font in any way? – idontknowwhoiamgodhelpme Mar 22 '17 at 19:26
  • Alright, i get it worked with minted. I will post a solution as an answer. But thanks anyway for your help! – idontknowwhoiamgodhelpme Mar 22 '17 at 19:51

This is my solution, for anyone else:


is the answer. You can change the style of your minted code with this. Examples can be found here: https://help.farbox.com/pygments.html

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.