How do you copy shell output into a note?

Hi all! Would anyone want to share their best practice how you record relevant output from a terminal inside your notes?

I use it currently while learning new commands/tools for linux, so I often have the original command in a code box but then I also want the output this command produces inside the note. Because I want to keep the formatting I mainly take screenshots, but I’m not so happy with that, I’d prefer text, but doing both seems excessive and clutters the note.

What I’m trying to do

I’m trying to have the output as it was displayed in my terminal inside the note.

As displayed in Obsidian (formatted as shell).

It diverges from the original, the color of the username is lost and numbers are highlighted in another color (and it only does so for complete numbers and not for hex-codes).
image

Things I have tried

I’m not happy with the display of numbers with the default config in Obsidian codeblock so I tried some codeblock formatters, but it seems like a lot of overhead for such a simple application as I do not use codeblocks otherwise.
I also tried dabbling with CSS but creating it from scratch except for really simple cases is beyond my knowledge and LLMs will only go so far…

That’s why I wanted to step back and ask you all. Maybe I am missing a simple step? How do you treat output from terminals inside your notes? Do you note it at all? Or just printscreen and forget about it? Alt-text?

Try something like:

$ sudo cryptsetup luksDump /dev/nvme0nlp3 | column &> your-note.md

You might need to play with the “column” command’s options.

I tested this with:

$ ls | column &> out.txt

and it worked.

1 Like

When I get syntax highlighting that I don’t like, I usually turn it off altogether by specifying it as text (instead of shell or whatever). In this case the only original formatting that would be lost is the color of the username.

1 Like

If you’re looking for a better syntax highlight, check out plugins:
HK Code Block is great, but you’ll find a few others if you check Obsidian’s community plugin list

Also check out MassCode to use instead of Obsidian to store, organize, find code snippets. To everyone his or her beer :beer_mug:

1 Like

thx @kbrede @CawlinTeffid and @Jopp for your inputs. As is the case most of the time, there is not really an easy solution :slight_smile:
I will stick with Obsidian defaults and try to ignore the bizarre formatting so as to not fall into the plugin-rabbit-hole.

You could technically use HTML to kind of get the formatting right, but it would be much less time consuming to just screenshot it and insert the screenshot into the note. That is one of the limitations of markdown and lack of inherent support for color.

I did a test and tried the HTML formatting and it was a mess honestly. After about an hour fooling around in Sandbox I gave up. CSS might be a little easier but you’re still going to have a nightmare for formatting. If you decide to try the HTML route, I discovered this after all my testing and it has a few different resources that may or may not work quicker than a screenshot: https://stackoverflow.com/questions/2033268/how-to-convert-linuxs-shell-output-to-html

@Jopp MassCode looks really cool. Kind of makes me wish I enjoyed programming more….kind of. :rofl:

With css you can improve formatting, but not highlighting. For this you’ll need one of Obsidian’s community plugins.

Yes, MassCode is great, because so simple to use, with ready made tools and some nice features like mermaid diagrams, developer utilities, stylish previews.
On Linux you can download ULauncher, ULauncher’s MassCode plugin to paste very quickly your atomic snippets and fragments.

Yes programming should be effortless/fun too and this builds upon the right toolset and focused interest in designs and workflows useful to you everyday.

Obsidian is more a gardener tool (study), whereas MassCode just a simple snippet manager (archive). I tried to use Obsidian as code manager too, but this didn’t work well.