POSTS
Motivated by laziness
Computers are the greatest inventions for lazy people ever. Just today, my wife ordered dinner while lying in bed. I’m a big fan of laziness through ingenuity, where clever design results in great reward for minimal effort.
One way I measure effort is how many keystrokes I need to fulfill a certain task over my lifetime. So if I do a task that takes ~300 keystrokes, but I’ll probably only do it once in my life, then I just do it and get it over with. However, once it becomes apparent that a task will be done several times in my life (or week, or day), it’s time to script.
As an example, here’s the evolution of how I check DNS records.
- Originally, it involved cd’ing to the directory (e.g.
cd ~/src/chef/cookbooks/dns/
). I’ll usegit grep
to find the record, but I’ll do agit checkout master; git pull upstream master
to make sure I’ve got the latest records. - Given the frequency I run
git checkout master
andgit pull upstream master
, it makes sense to use git’s alias functionality to shorten them togit com
andgit pum
. Bonus - this makes other parts of my workflow faster. - Another part that takes a bunch of keystrokes is changing to the DNS
cookbook directory. I alias dns_cookbook to
cd ~/src/chef/cookbooks/dns
. This is much shorter and easier to remember, and I get tab completion as well. Bonus -this also makes it quicker to get to the directory for other DNS tasks. - There’s 4 separate steps so far: changing directory, checking out
master, pulling the upstream master, and running git grep. Seems ripe
for a script, right? I create a little shell script called
dnsgrep
, which passes its argument togit grep
. Bonus - I can tab completednsgrep
with “dnsg<tab>”, so it’s really only 5 keystrokes
So in summary:
cd ~/src/chef/cookbooks/dns; git checkout master; git pull upstream master; git grep <thing>
vs.
dnsgrep <thing>
I save 77 keystrokes every time I want to do this. Assuming I do this at least 250 times a year (at least), that’s 19250 keystrokes saved (after the initial scripting).
The important part in this win isn’t the keystrokes saved, though. It’s the amount of mental exertion required.
- “I want to grep DNS records”
- “I change directories”
- “I check out master”
- “I pull upstream master”
- “I grep DNS records”
vs.
- “I want to grep DNS records”
- “I grep DNS records”
I’ve removed the steps between “I want” and “I do”. I get to be lazy, I get results faster, and drastically reduced the possibility of typing error.