Home

Awesome

<div style="margin-top: -20px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⏫ Remember to enable! <!-- Meant for Obsidian community plugin list view. --></div>

Shell commands plugin for Obsidian

This plugin lets you define shell/terminal commands in settings and run them quickly via Obsidian's command palette, or via hotkeys. Use note related variables as part of the commands, and insert output back to your notes, if you wish. This is a Swiss army knife when it comes to accessing external applications from Obsidian, and you are the one who defines its tools.

You can customise your commands with built-in variables that can provide the current file title/name/path, current file's parent folder name/path, and date/time stamp with a custom format.

A changelog is available in a separate file.

WARNING: Be careful with system commands! Only use commands that you know and trust. If you are copying and pasting commands from the internet or from files written by other people, you need to understand precisely what those commands do! Otherwise, you might lose your files, or screw up your system!

Linux: If you have installed Obsidian using Flatpak, shell commands are executed in an isolated environment, which may cause unexpected behaviour or error messages. Please consider other installation options.

The plugin is still in its early development stage. Use at your own risk, and note that when you upgrade the plugin, things may break.

This plugin doesn't come with any kind of warranty in case it does something bad to your files! If you know programming, check the source code in GitHub so you know how it executes commands.

Main issues

For future ideas, see the Discussions section.

Installation & usage

  1. Search for this plugin in Obsidian's community plugins settings panel.
  2. Click Install, and after that remember to click Enable!
  3. Head to Shell commands settings tab.
  4. All commands will be run in a certain directory. By default, it's your vault's base directory. If you want to run the commands in some other directory, you can type it in the Working directory field.
  5. Define one or more commands by clicking the New command button and entering a command. Read variable usage instructions in the settings panel if you need them.
  6. For advanced settings, such as a command alias name that appears in the command palette instead of the actual shell command, or an ability to direct command output to a currently active note, click a small gear icon next to the shell command.
  7. All commands that you have defined, will be added to Obsidian's command palette. You can execute them from there (by hitting Ctrl/Cmd + P and searching for your command) or you can define a hotkey for each individual command in Obsidian's Hotkeys settings tab.

Extensive documentation

... is available right here: https://publish.obsidian.md/shellcommands

Usage examples

Example shell commands have been moved to: https://publish.obsidian.md/shellcommands/Example+shell+commands/Example+shell+commands

Escaping special characters in variable values

(Todo: check that the Documentation has all this content, and then remove this section from README.md.)

Note that special characters (= anything else than letters, numbers and underscores _) are automatically escaped in variable values. Escaping depends on the shell that you use, but generally speaking, each special character is prefixed with an escape character, which might be \, ` or % depending on shell.

Without escaping, if you would have a command and a quoted string parameter like mycommand {{clipboard}}, it might break if your clipboard content contains > characters, because those would be inserted into the command as-is. Your command might end up looking like this: mycommand Text pasted from clipboard that contains a > character. The > character would redirect output to a file and might overwrite an important file. That's why escaping is in place, making the aforementioned command look like this: mycommand\ Text\ pasted\ from\ clipboard\ that\ contains\ a\ \>\ character\. (when the shell is Bash). Your shell then parses the escaped special characters and uses them as literal letters, not as special characters.

If you want to avoid escaping special characters in variable values, you can use {{!variable}} syntax, meaning that you can add an exclamation mark ! in the front of a variable's name. Note that this can be dangerous, and you need to understand very well what you are doing if you use this kind of raw, unescaped variable values! In most situations, you should be able to use escaped variables really well.

Benefits from other plugins

Not a single plugin can be great just by itself. And not a single plugin suits every situation. Here I'm collecting a list of plugins that can be good companions or good alternatives to Shell commands.

<!-- Keep in alphabetical order! -->

(Thanks FelipeRearden for telling me about many of these plugins!)

Tested platforms

Here is a list of operating systems this plugin has been tested on, along with Obsidian version and the plugin's version (= SC, Shell commands).

Shell commands versionWindows 10Linux (Xubuntu 22.04)Mac
SC 0.23.0Obsidian 1.7.5<br>WorksObsidian 1.7.5<br>Works
SC 0.22.0Obsidian 1.5.12<br>WorksObsidian 1.5.12<br>Works
SC 0.21.0Obsidian 1.5.3<br>WorksObsidian 1.5.3<br>Works
SC 0.20.1Obsidian 1.3.5<br>WorksObsidian 1.3.7<br>Works
SC 0.20.0Obsidian 1.3.5<br>WorksObsidian 1.3.5<br>Works
SC 0.19.1Obsidian 1.3.4<br>WorksObsidian 1.3.4<br>Works
SC 0.19.0Obsidian 1.3.4<br>WorksObsidian 1.3.4<br>Works

Linux version has changed from Xubuntu 20.04 to 22.04.

Shell commands versionWindows 10Linux (Xubuntu 20.04)Mac
SC 0.18.2Obsidian 1.1.16<br>WorksObsidian 1.1.16<br>Works
SC 0.18.1Obsidian 1.1.12<br>WorksObsidian 1.1.12<br>WorksObsidian 1.1.12<br>Tested that fix #314 works.
SC 0.18.0Obsidian 1.1.9<br>WorksObsidian 1.1.9<br>Works
SC 0.17.0Obsidian 1.0.3<br>WorksObsidian 1.0.3<br>Works otherwise but there's the already reported newline bug.
SC 0.16.0Obsidian 0.16.3<br>WorksObsidian 0.16.3<br>Works
SC 0.15.0Obsidian 0.15.9<br>WorksObsidian 0.15.9<br>Works
SC 0.14.0Obsidian 0.15.6<br>WorksObsidian 0.15.6<br>WorksmacOS: Monterey 12.4 (21F79) <br>Obsidian: 0.15.9<br>Works otherwise but there's a newline bug. Tested by gapmiss, thank you! 🙂
SC 0.13.0Obsidian 0.14.15<br>WorksObsidian 0.14.15<br>Works
SC 0.12.1Obsidian 0.14.6<br>WorksObsidian 0.14.6<br>Works
SC 0.12.0Obsidian 0.14.6<br>WorksObsidian 0.14.6<br>Works
SC 0.11.1Obsidian 0.13.23<br>WorksObsidian 0.13.23<br>Works
SC 0.11.0Obsidian 0.13.23<br>WorksObsidian 0.13.23<br>WorksmacOS: 11.6 <br>Obsidian: ?<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.10.0Obsidian 0.13.23<br>WorksObsidian 0.13.23<br>WorksmacOS: 11.6 <br>Obsidian: ?<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.9.0Obsidian 0.12.19<br>WorksObsidian 0.12.19<br>Works
SC 0.8.0Obsidian 0.12.19<br>WorksObsidian 0.12.19<br>WorksmacOS: 11.6 <br>Obsidian: 0.12.19<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.7.1Obsidian 0.12.19<br>WorksObsidian 0.12.19<br>Works
SC 0.7.0Obsidian 0.12.19<br>WorksObsidian 0.12.19<br>WorksmacOS: 11.6 <br>Obsidian: 0.12.19<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.6.1Obsidian 0.12.19<br>WorksObsidian 0.12.19<br>Works
SC 0.6.0Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>WorksmacOS: 11.1 <br>Obsidian: 0.12.15<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.5.1Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>Works
SC 0.5.0Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>WorksmacOS: 11.1 <br>Obsidian: 0.12.15<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.4.1Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>WorksmacOS: 11.1 <br>Obsidian: 0.12.15<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.4.0Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>Works
SC 0.3.0Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>WorksmacOS: 11.1 <br>Obsidian: 0.12.15<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.2.0Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>WorksmacOS: 11.1 <br>Obsidian: 0.12.15<br>Works, tested by FelipeRearden, thank you! 🙂
SC 0.1.1Obsidian 0.12.15<br>WorksObsidian 0.12.15<br>Works
SC 0.1.0Obsidian 0.12.12<br>WorksObsidian 0.12.12<br>WorksmacOS: 11.5.2<br>Obsidian: 0.12.5<br>Works, tested by skipadu, thank you! 🙂
SC 0.0.0Obsidian 0.12.12<br>WorksObsidian 0.12.12<br>Works

As I do not own a Mac, tests on Mac are performed by other people, and I cannot guarantee that every version will be tested on Mac. That's the reason why Mac might not appear on every row in the above table. If you notice that the newest SC version does not have a Mac test record in the table, you can help by performing a Mac test yourself and submitting your freeform test result here.

Ask for help

If you have any questions about how to use this plugin, please feel free to start a discussion on GitHub, or post in the plugin's Obsidian.md forum topic.

Contributing

Ideas, feedback, pull requests etc. are all welcome! :)

Author

For all authors, see AUTHORS.md.

Developer

Jarkko Linnanvirta

Contact:

Supported by

This project is free open source software and receives no funding. I want to thank the following parties for kindly supporting this project by giving free licenses/service subscriptions.

<img alt="JetBrains Logo (Main) logo" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg" style="height: 4em"></img> JetBrains

JetBrains offers me the ability to use their WebStorm editor free of charge for developing the Shell commands plugin. Read more about JetBrain's open source support.

<img alt="WebStorm logo" src="https://resources.jetbrains.com/storage/products/company/brand/logos/WebStorm.svg" style="width: 300px;">

Obsidian

Obsidian developers offer this project:

Copyright

Copyright (C) 2021 - 2023 Jarkko Linnanvirta (see other authors in AUTHORS.md).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

The full license is available in the GitHub repository of this project.