Shell Commands in Obsidian Feels Like Cheating

Published: May 09, 2022

I'm a big fan of shell commands. These are little scripts that you write that can automate tasks for you. To me, it's one of the fundamental avenues for automation. Here's an example

echo 'Hello world' > Desktop/hello.txt
cp ~/Desktop/hello.txt ~/Documents/

Okay, so the above script doesn't really do anything exciting, but hopefully you can see how creating, moving, copying programmatically can be achieved. When you start to get really into shell scripting, you can do some really fancy stuff, kind of like how I create blog posts in Obsidian and copy them into my blog when I'm done.

Here's that script:

Copy to Blog

echo "\{\{file_name}}" | sed -e 's/ /-/g' -e 's/\\//g' | awk '{print tolower($0)}' | xargs -I {} cp Blog/ ~/Sites/thenerdscribe-blog/posts/{}

Publish to Blog

cd ~/Sites/thenerdscribe-blog; git add --all; git commit -am "New post" && git push

I'm using the Obsidian Shell Commands plugin to achieve this. Essentially all this command does is change the file name that I have in Obsidian into a better version for my blog, then copies the file into the blog. It then runs some git commands to publish it. That's it! Super handy as I can "export" my blog post and then have it published in a matter of seconds.

I implore you to explore shell commands especially in Obsidian. It's a fun combination that gives you a ton of power.