The Command Line plugin enhances how command line code blocks are handled in Obsidian, streamlining workflows for users who document or share terminal commands. It allows copying commands directly from code blocks without manually selecting text, automatically stripping out prompts and command output so the clipboard content is clean and ready to paste into a terminal. The plugin supports different command-line styles, including shell, batch, and PowerShell, with automatic prompt detection and default values for each type.
command-line
as an alternative to highlighted languagesThis plugin adds enhanced support for command line code blocks to Obsidian.
Command line code blocks are identified using one of the following languages:
Name | Highlight | Prompt Pattern | Default Prompt | Continuation |
---|---|---|---|---|
command-line |
N/A | Any below | C:\> |
Any below |
batch-command |
batch |
/\S*?>/ |
C:\> |
^ |
powershell-command |
powershell |
/\S*?>/ |
PS> |
` |
shell-command |
shell |
/\S*?[#$%]/ |
$ |
\ |
For example, copying the following code block to the clipboard will remove the
prompt and output while preserving line continuations and white space:
```shell-command
$ command with \
line continuation
and output, which will be removed
from the clipboard.
```
[!NOTE]
If clipboard normalization is enabled in Settings, unnecessary white space
(including line continuations) will be removed in addition to the prompt and
output.
Pull requests are welcome! See CONTRIBUTING.md for details.
Source code in this repository is licensed under a Simplified BSD License. See
LICENSE for details.