How to highlight the bash/shell commands in markdown files?
For example to highlight js
I write:
```js
function () { return "This code is highlighted as Javascript!"}
```
To highlight HTML code I use ```html
.
How can we highlight bash/shell commands?
If you are looking to highlight a shell session command sequence as it looks to the user (with prompts, not just as contents of a hypothetical script file), then the right identifier to use at the moment is console:
Per the documentation from GitHub regarding GFM syntax highlighted code blocks
Rendered on GitHub,
console
makes the lines after the console blue.bash
,sh
, orshell
don't seem to "highlight" much ...and you can useposh
for PowerShell or CMD.using the knitr package:
e.g.:
you can also use:
engine='sh'
for shellengine='python'
for pythonengine='perl'
,engine='haskell'
and a bunch of other C-like languages and evengawk
,awk
etc.I find good description at https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
Although I could not find any official git hub doc about using
highlight.js
, I've tested lots of languages and seemed to be workingTo see list of languages I used https://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases
Some shell samples:
Example:
Depends on the markdown rendering engine and the markdown flavour. There is no standard for this. If you mean github flavoured markdown for example,
shell
should work fine. Aliases aresh
,bash
orzsh
. You can find the list of available syntax lexers hereBitbucket uses CodeMirror for syntax highlighting. For bash or shell you can use
sh
,bash
, orzsh
. More information can be found at Configuring syntax highlighting for file extensions and Code mirror language modes.