I’d like to display config files incl. filename and their file contents in a code block, which would be a handy task for admins.
Things I have tried
As long as the config filename does not contain a file extension (separated by a dot), this already works out of the box with Obsidian core. As we can see in the following screenshot, the filename /etc/ssh/sshd_config is displayed properly:
However, this does not work if the filename contains an extension, since the file extension gets cut off, In this particular case etc/sysctl.conf becomes /etc/sysctl without the .conf extension:
I do understand I’m misusing the code block feature for something (using config filenames instead of programming languages as a title) it’s not supposed to be used for. This would a great feature anyway. I’m writing the filename above or below the code block as a workaround, although this is not ideal.
Unfortunately, I don’t believe there’s a way to natively achieve this. One trick I’ve used is to nest the code block inside of a Callout. Something like:
It’s still a plugin, but I’ve found the Code Styler plugin to be an interesting option when I want to some extra embellishment for a code block. It doesn’t need to do anything beside the native look, but it do allow for a lot of different styling if you want to. Most notably by adding title:/etc/ssh/sshd/config.cong it’ll add a title to your code block
So your example could look like:
``` title:/etc/sysctl.conf
line 1
line 2
line 3
```