bugen28 downloadsEnhance fenced code blocks (codeblocks) and code snippets with headers, line numbers, and folding. Display shell commands and ANSI output in a terminal-style layout.

Motto Code Block makes code blocks easier to read in Obsidian with theme-aware headers, line numbers, and folding. It also displays shell commands and their output in a terminal-style layout.
Code blocks adapt to your active Obsidian theme's colors and styling, in both light and dark modes.
| Light mode | Dark mode |
|---|---|
![]() |
![]() |
title: or file: are present. Set Header display to Always in settings to show them on all eligible blocks.
Command Block presents shell commands and their output in a terminal-style layout. Copy individual commands without prompts, show or hide output with a click, and display ANSI-colored output. Commands are displayed, not executed.

Add options after the language name on the opening code fence. Quote values that contain spaces.
| Option | Description |
|---|---|
title:"My code" or file:example.py |
Set the header title. |
fold / expand |
Start folded / fully expanded. |
expand:5 |
Show a partial preview of the first five lines. |
header-style:info |
Color the header using an Obsidian callout type. |
cmd |
Render a sh, bash, zsh, csh, or fish block as a Command Block. |
prompt:"user@host:~/project" |
Show the user, host, and working directory in a Command Block header. |
user:, host:, cwd: |
Set the prompt fields individually. |
exclude |
Disable this plugin's enhancements for the block. |
For example, file:manhattan_distance_contours.py adds a file name to a Python block's header:
```python file:manhattan_distance_contours.py
size_x, size_y = 15, 9
chars = "\u2588\u2593\u2592\u2591\u0020"
for y in range(-size_y, size_y + 1):
line = ""
for x in range(-size_x, size_x + 1):
dist = abs(x) + abs(y)
line += chars[dist % len(chars)] * 2
print(line)
```

For a Command Block, combine cmd with an optional title and prompt. To include output, paste it into an ansi block directly after the shell block, with no blank line between the blocks:
```bash title:"Manhattan Distance Contours" prompt:bugen@localhost:/home/bugen
python manhattan_distance_contours.py
```
```ansi
... pasted output ...
```

Code blocks retain Obsidian's syntax highlighting and use your active theme's colors by default, rather than a separate plugin color scheme.
Use Language include list and Language exclude list in settings to choose which languages are enhanced. Exclude languages handled by other plugins to help avoid rendering conflicts. Mermaid is excluded by default.
Thanks to these projects and their contributors:
See THIRD_PARTY_NOTICES for attribution and license details.
