Transform highlighted text with system commands from within Obsidian

I wrote an article that explains how to run system commands and display the results in Obsidian. With this technique you can pass text to commands and have them modify your content. For example formatting, extracting, rearranging, replacing, etc…

It’s very powerful, flexible, and may save you some tedious busy work when you’ve got lots of text to edit.

https://medium.com/@gareth.stretton/obsidian-do-almost-anything-really-with-system-commands-b496ffd0679c

It uses the Templater plugin to pass selected text to your shell (e.g. bash or zsh)

Enjoy!

7 Likes

Update: wrote a part two that makes this easier :grinning:

https://medium.com/@gareth.stretton/obsidian-part-2-system-commands-cdc20836a2b8

3 Likes

Nice out-of-the-box thinking. Would have never occurred to me to write shell commands into the note and then run templater on the note this way.

Minor bug: in your blogpost, it should rather be bash -c "$cmd" since that’s how the variable is named in the Templater script

CleanShot 2023-02-24 at 12.04.37

Good spotting!

Thanks for the detailed description and screenshot.

I updated the template to use “COMMAND” instead – to be consistent with the previous post and images.

Thanks pseudometa

1 Like