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 script, for example, looks like this:

#!/usr/bin/env bash

pushd /home/botond/Sync/blog

bundle exec jekyll build
ssh "rm -rf /var/www/*"
scp -r ./_site/*

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


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 :)