Hi all,
Shell commands lets you define custom shell commands in settings and then run them via hotkeys or command palette. You can use it to open external applications or for automated processing of files. A few built-in variables are supported, so you can supplement your commands with for example current file path/folder, current date/time, selected text, clipboard content etc.
Examples
A few example commands (for Windows*):
-
start git-gui
: Open a graphical Git client for committing changes in your vault to a repository. -
start cmd
: A quick way to run other commands that you have not defined in the settings. -
mkdir {{date:YYYY-MM}}
: Create a monthly folder like 2021-08. -
echo {{clipboard}} >> NewNote.md
: Create a new file and paste content there from clipboard. -
start https://duckduckgo.com/?q={{selection}}
: Search the web using text you have selected.
The plugin does not predefine any commands, those are only example ideas.
*) Supported platforms are Windows, Linux, and Mac. You need to customise the given examples if you want to use them on Linux or Mac. Mobile is not supported. Iād like to investigate if itās possible to run shell commands in the mobile app. Currently, itās really uncertain to me (help is welcome ).
Note that for the sake of simplicity, there is no escaping done for variable values. If you have a command and a quoted string parameter like mycommand "{{clipboard}}"
, it might break if your clipboard content contains "
quote characters, because those are inserted into the command as-is. Your command might end up looking like this: mycommand "Text pasted from clipboard that contains a " character."
Still being tested
This plugin in still in its 0.x era, meaning that there might be things that do not work as intended or things that could be improved. But the basic functionality that I wanted it to have is already there. Iād like to receive feedback about this plugin. If you have ideas for new features, new variables, improvements or fixes, you can freely write them to:
- Shell commandsā GitHub issues - the easiest for me to work on these ideas.
- In this topic - in case you donāt have a GitHub account or if itās just general feedback or questions how to use this plugin.
Iām open to all discussion about how to change and improve this plugin in the future.
A word of warning
Be careful with system commands! Only use commands that you know and trust. If you are copy 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! This plugin doesnāt come with any kind of warranty.
P.S.
I also noticed another plugin that has the ability to run shell commands: Text Expander Plugin. It lets you write shell commands in your MarkDown files and run them from there, which might be better suited for some situations, such as scripts that are long or that need to be previewed every time before running them. My plugin works best for simple, short commands, even though you can run multiple commands by concatenating them with &
in windows or &&
in Linux and Mac.