back to TILs

Shell in Markdown

For a long time, I’ve used commandline as the name for the syntax of code fences in markdown whenever I’ve wanted to denote a shell command or session.

I’ve now realized that I’ve been using the wrong name, and also that there are two separate scenarios to keep in mind:


The first scenario is one-off commands, which should use the syntax sh, or shell. This would be showing something you’d enter directly at the command line.

For example:

brew install git

I leave out the command prompt, because it’s implied by the context that the line is to be entered in a command line. Also, it helps with copy-paste.


The other scenario is showing a shell session, which typically shows the command prompt, an entered command, and the response to the command. In this instance I’d use the console, or sh-session syntax.

For example:

$ git st
?? content/til/markdown-shell.md

🐚