WEB Advent 2012 / Be Lazy

The other day, I went to help a co-worker set up his laptop. When teaching new topics, I’m a big fan of active participation, letting the other person drive as a means to better understanding. So, during the setup, I explained what we were doing, what changes we were making and why, but insisted he make the actual changes on his system.

Watching him work, it quickly became apparent that--while he knew what he was doing--he wasn’t efficient. Using the tools on his laptop was onerous; he fought the system, taking the long way each time to achieve the desired results, but at the cost of lost time for both of us. As I was watching him, I wished he were more lazy.

Wait. Lazy? Well, sure.

Laziness is the first great virtue of a programmer:

“The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don’t have to answer so many questions about it. Hence, the first great virtue of a programmer.”

—  Larry Wall

Fortunately, laziness isn’t just for programmers; it’s for all who work and take pride in their accomplishements, and with computers, it’s possible to be lazy (and efficient!) with just a little effort.

And, look at all the ways you can be lazy!

App launchers

Moving hands away from the keyboard, or away from their default position if you use a secondary input device consistently, inherently creates inefficiencies. Use an app launcher that you can customize. Four or five keystrokes is all I need to open just about any app on my system: two to open the launcher, one or two to select the app or file, and enter to open it. You can also use app launchers to set up scripts and run workflows.

On OSX, options include Alfred, Launchbar, and Quicksilver.

On Linux, options include Gnome Launch Box, Gnome Do, and Launchy.

On Windows, options include Skylight and Launchy.

Launchy also lets you use Python to extend its functionality, so you can automate common work patterns.

Or, if you’re on OS X, use the highly-underrated Automator workflows for tasks on your system. You can have your workflows triggered manually or automatically. An example could be instead of the default action to import all photos into iPhoto whenever you mount an SD card, you could have all images post to a private folder on OpenPhoto and tag them with the date.

Befriend the command line

Not all workflows, however, need be triggered from an app launcher or automatically. Using the command line, you can trigger most apps to run just the way you want. While some developers may roll their eyes, not everyone uses the command line. Befriending the command line is the best form of laziness.

If you’re on a Unix platform — yes, that includes OS X — these twelve commands will get you going: cd, cp, less, which, ls, rm, pwd, cat, find, grep, !!, and !$.

Want to execute the last command again?


Want to repeat a command you typed in a while ago?


Want to go to the beginning of a line?


Want to go to the end to edit the last argument?


Want to switch back to your previous directory?

cd -

Want to look through your history to find the command you ran a while ago?


My personal favorites are pushd and popd, with dirs to tell me where I am.

pushd with an argument will add the current directory (pwd) onto the directories stack (listed with dirs) and change the working directory to the one specified by the argument:

% pwd
% pushd ~/work/projects/web-advent
~/work/projects/web-advent ~
% pushd ~/work
~/work ~/work/projects/web-advent ~
% dirs -v
0       ~/work
1       ~/work/projects/web-advent
2       ~

pushd without arguments will swap the top two directories on the stack — the same behavior as cd -.

% pushd
~/work/projects/web-advent ~/work ~
% dirs -v
0       ~/work/projects/web-advent
1       ~/work
2       ~

The advantage here is when you have a number of places you need to be working:

% dirs -v
0       /usr/sites/example.com/8929/website
1       /var/log/apache2/example.com/
2       /etc/apache2/extra
3       /home/kitt/work/reports/example.com

Using the +N notation moves you among the directories, either popping the Nth directory to the top of the stack, or rotating the stack around N positions:

% pushd +2
/etc/apache2/extra /usr/sites/example.com/8929/website /var/log/apache2/example.com /home/kitt/work/reports/example.com
% d
0       /etc/apache2/extra
1       /usr/sites/example.com/8929/website
2       /var/log/apache2/example.com/
3       /home/kitt/work/reports/example.com

I’m lazy even when using pushd, popd, and dirs -v. I have them aliased to pu, po and d. I alias my commands heavily, setting up aliases for project directories, common commands I run frequently, and uncommon commands (I hate trying to remember the full syntax).

If you run an even semi-complicated command more than once, write an alias. No one wants to type in this command more than once:

alias gen_ctags='/usr/local/bin/ctags \
  --langmap=php:.engine.inc.module.theme.php.install.test.profile \
  --php-kinds=cdfi --languages=php --recurse --exclude="\.git" \
  --exclude="\.svn" --exclude="\.hg" --exclude="\.bzr" \
  --exclude="CVS" --totals=yes --tag-relative=yes \
  --regex-PHP="/abstract\s+class\s+([^ ]+)/\1/c/" \
  --regex-PHP="/interface\s+([^ ]+)/\1/c/" \
  --regex-PHP="/(public\s+|static\s+|abstract\s+|protected\s+|private\s+)function\s+\&?\s*([^ (]+)/\2/f/"'

Practice and repetition are the best ways to learn shortcuts. If you’re looking for a concentrated resource, ShortcutFoo for the command line is a great one.

ShortcutFoo also has drills for learning how to use the shortcuts for a large number of programs, including a number of editors.

If you’re a developer, the best thing you can do for efficiency and, well, laziness, is to become proficient in your editor, learning its shortcuts and learning how to write editor macros. If your chosen editor doesn’t have macros, pick a different editor; no need to handicap yourself with a tool that doesn’t actively help you be lazy.


When looking at editors or writing macros, anyone who writes any significant HTML should look at the Emmet (formerly Zen Coding) plugins.

The easiest example of how powerful Emmet can be is the abbreviation expansion, which takes a abbreviated line like this:


And, expands it into this:

<div id="banner">
 <div class="logo"></div>
 <ul id="navigation">
   <li><a href=""></a></li>
   <li><a href=""></a></li>
   <li><a href=""></a></li>
   <li><a href=""></a></li>

Emmet also provides editing shortcuts, tag manipulation (matching, removing, navigating to), and other generators (vendor prefixes, gradients).

There are, of course, thousands of other ways to be more efficient and lazy in a common workday. Being aware of repetition, asking co-workers how they accomplished a task faster than you, and recognizing that laziness can be a virtue are ways to increase that efficiency and leave room for more important things in life.

Like relaxing. Or, doing nothing.

Other posts