+++
title = "Syntax highlighting for console snippets"
date = 2020-05-19
+++

Finally, I moved my blog from wordpress to a static site. I chose [zola](https://www.getzola.org/) as the
site generator, because most of my documentation nowadays is in markdown anyway.

Syntax highlighting was a badly missed feature for me in the past. And zola delivers :-)

The only thing missing was syntax highlighting for `console` (terminal) snippets.
<!-- more -->

I need it to display e.g.:
```console
$ cd /lib/systemd/system
$ for i in fedora*storage* lvm2-monitor.* mdmonitor*.*; \
 do sudo systemctl mask $i; \
 done
```

with
``````
```console
$ cd /lib/systemd/system
$ for i in fedora*storage* lvm2-monitor.* mdmonitor*.*; \
 do sudo systemctl mask $i; \
 done
```
``````

TLDR: [git repo](https://github.com/haraldh/Sublime-console)

Using `bash` as the language indicator does not really fit. 

``````
```bash
$ echo "Hello World" # comment
Hello World
$ echo -e ""

```
``````

renders as

```bash
$ echo "Hello World" # comment
Hello World
$ echo -e ""

``` 

It does not honor the shell prompt, so I took the sublime files for `bash` and extended them for `console`.

``````
```console
$ echo "Hello World" # comment
Hello World
$ echo -e ""

```
``````

renders as

```console
$ echo "Hello World" # comment
Hello World
$ echo -e ""

``` 

as would a

``````
```bash
echo "Hello World" # comment
echo -e ""
```
``````

```bash
echo "Hello World" # comment
echo -e ""
``` 

Note: as you can see, the `echo` is not colored in the second line,
so I filed an [issue](https://github.com/sublimehq/Packages/issues/2367)
for the sublime bash syntax source.

I still have to figure out how to handle
``````
```console
# echo "Hello World"
# echo "Hello World"
```
``````

```console
# echo "Hello World"
# echo "Hello World"
``` 

although this seems to work:

``````
```console
# echo "Hello World"
Hello World
# echo "Hello World"
Hello World
```
``````

```console
# echo "Hello World"
Hello World
# echo "Hello World"
Hello World
``` 

Nevertheless, I uploaded the console sublime syntax to a [git repo](https://github.com/haraldh/Sublime-console).

Feel free to use it.
