From beea427f0336a1e212ae9f94f53a6366b4b39220 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 19 May 2020 20:38:44 +0200 Subject: [PATCH] add console article --- content/console.md | 125 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 content/console.md diff --git a/content/console.md b/content/console.md new file mode 100644 index 0000000..a3c9268 --- /dev/null +++ b/content/console.md @@ -0,0 +1,125 @@ ++++ +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 deliveres :-) + +The only thing missing was syntax highlighting for `console` (terminal) snippets. + + +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. \ No newline at end of file