Hugo - How to display the $ Shell Prompt in your Code Snippets
To display the $
Bash or shell prompt symbol at the start of your code snippets with Hugo, you need to add some CSS.
This will also cause the cursor to ignore the $
symbol when someone wants to copy the content of the code snippet block, which is a nice bonus.
code.language-bash::before {
content: "$ ";
}
If you then create a code snippet with the bash syntax…
```bash
echo 'hello world' && exit 1
```
…It will look like this:
echo 'hello world' && exit 1
Note: This will only show the symbol at the first line of each code block that has the bash syntax assigned:
echo 'hello world'
exit 1