A lot of the posts I write include command-line interface (CLI) commands to type in. I’ve found over time there are things I can do to improve how these commands are communicated.
When writing a command inline, wrapping it in
<code></code> tags works well (e.g.
When you want to display it as a block, wrapping it in
<pre><code></code></pre> works well, e.g.
The CLI Prompt
There are varying opinions on whether or not your examples should include your command prompt.
When to Include the Prompt?
My recommendation is to omit the command prompt in almost all cases. It is easier to copy the command when the prompt is not included (both manually and if you have a copy button associated with your block).
|Block w/ Output||
The only time I recommend including the prompt is when the block includes both the typed command and the output because in this case the prompt differentiates the command to be typed and the expected output.
In the rare occasions when you do include the prompt I recommend using
$ (the default prompt in bash shell).