Plugin to enable shell scripted functions from the community

Sorry for bringing up an old topic. I just wanted to post in case someone is still interested.

I didn’t read all of the messages, but I thought about this:

I have developed a plugin named Shell commands (GitHub / Topic on this forum). It’s not 100% what you are looking for, but I’d like to see if it can do at least some of the mentioned things. (Also, one reason for me to write this post is to get ideas on how to develop it further.)

A quick description

The Shell commands plugin lets users create system commands in its settings, and presents them in Obsidian’s command palette (with the ability to assign hotkeys). It’s a bit different than your idea about defining shell commands in the note content, but hold on, maybe something similar can be achieved.

Variables - get data from the current note

There are a few variables supported, that can be used to pass data from Obsidian to the shell commands, for example {{file_path}}, which gives the currently open file’s directory and file name. This could open up some kind of possibility to pass the file path to some command line program that executes its content, e.g. python {{file_path:absolute}} - if the file content is completely python source code.

Another variable is {{yaml_value}}. Instead of having the whole file content be considered as source code, you could just have a YAML property that defines the script:

---
python_code: "my short python script here"
---

And the shell command: echo {{yaml_value:python_code}} | python
This is not good for anything longer than one line of code, because it’s not convenient to present in a YAML property. But maybe this opens up some further ideas.

Output channels - flood your notes

The plugin lets you define where the output of a shell command should be put:

  • Current file: insert into the beginning or end of the current note, or at caret location (possibly replacing text if something was selected).
  • Open a file: Consider the output as a file name/path that should be opened in Obsidian. Can be e.g. that your command writes some stuff to a new file and then outputs the file name for opening.
  • Other output channels exist, too, but maybe the Current file is the most relevant for this topic.
  • stdout and stderr can be handled separately, e.g. error messages can be shown as popup messages, while normal output can go to a file.

Events - execute shell commands automatically

Execute shell commands via links

Support for executing shell commands via Obsidian URI will be released in the future. It will allow creating custom links that can execute shell commands, with custom parameters supported.


I’m open to new ideas for the plugin, even though it’s not quite the same thing that was asked in this topic, but maybe it can provide some workarounds?