Blog Tags: 

Three strikes - time to automate!

I caught myself today repeating a few basic operations by hand what seemed like a zillion times. Over and over again. I didn't really notice it at the time but it was really slowing me down.

For example, after committing to tklbam I would create a tklbam testing package, copy the package to one of my test machines, install it and remove the archive.

It would take me about a minute to do this each time and I would never do it perfectly. Small mistakes would eat up my attention, like leaving an older version of tklbam in the same location and trying to figure out which is the newer version I need to install. It wasn't the big stuff that was cramping my style, but the small things. Paper cuts that were making it hard for me to concentrate.

All of a sudden I remembered an old rule I have - that if I repeat a sequence of operations three times in a single day, that signals it is time to automate that operation into an adhoc shell function.

cat ~/.bashrc.d/random-functions

ut() {
    if [ "$1" ]; then

        # finds tklbam within my CDPATH
        cd tklbam
        rm -f ../*.deb
        dpkg-buildpackage -uc -us -b
        scp ../*.deb $1:/
        ssh $1 'dpkg -i /*.deb && rm -f /*.deb'
    fi
}

# this installs the latest version of tklbam to coretest
ut coretest

Ah. That's much better.

Add new comment