Automate Everything

A very useful habit I picked up over the years is this:

If I catch myself doing the same thing on my computer at least three times, I try to write a script to automate it.

Even when I was using Windows, I mostly lived in the WSL Linux command line so this was pretty easy. Windows-specific things could be automated using PowerShell. (Seriously, if you’re a programmer using Windows, you must learn PowerShell. It is actually a pretty nice language – much nicer than Bash – and there is a cmdlet for everything).

Now that I’m on Linux, this became even easier. I have a ~/bin directory on my PATH and I put these tiny scripts there.

You can also automate tasks on remote servers. My deploy-blog.sh script, for example, looks like this:

#!/usr/bin/env bash

pushd /home/botond/Sync/blog

bundle exec jekyll build
ssh botond@botond.online "rm -rf /var/www/tatooinesunset.botond.online/*"
scp -r ./_site/* botond@botond.online:/var/www/tatooine-sunset.botond.online

echo Deployment finished - please check the website for any errors.

popd

This is very simple, primitive even, but it serves me well. It doesn’t even make a backup of the previous version. That is something I definitely should do later :)