A confession: I don’t really care that much about estimating the reading time of the stuff I write. I just thought it would be an interesting and easy little TextMate command, and it was. I spent more time looking up average reading speeds than writing the command or the post.

But after a link from Ben Brooks and interest from commenters Shawn Medero and Neil Gupta, I feel a compulsion to do the job right.

First, let’s redo the TextMate command (again). It takes very little effort to turn it into something that provides all the traditional wc information as well as the estimated reading time.

The command pipeline is now

bash:
wc -mwl | awk '{printf "Lines: %d\nWords: %d\nChars: %d\nTime:  %d:%02d", $1,$2, $3, int($2/250), int(\$2%250/250*60)}'


and the output is a tooltip with four lines of info.

The changes to the awk command are pretty obvious. The m in the -mwl option string added to wc causes it to count characters rather than bytes, a more appropriate choice in a multibyte, Unicode world.

Now to extend this idea beyond TextMate. Following Shawn Medero’s suggestion, I created a Service in Automator that runs that same command and shows the output in an alert box.

Here’s the Service:

The shell script is that same pipeline. The AppleScript that displays the output is this:

on run {input, parameters}
activate
set msg to item 1 of input & return & item 2 of input & return & item 3 of input & return & item 4 of input
display alert "Selected text" message msg as informational
end run


The hardest part of writing this script was learning that the input comes in as a list of strings, one for each line of the shell script’s output, rather than a single string. Thus that long set msg line that puts all the lines back together again. A zipped version of the Service can be downloaded from here.

With this Service, which I’ve also bound to the ⌃⌥⌘R keystroke combination,1 I can get the same information in any application. I still think the TextMate command is valuable, though, because it doesn’t force me to select text before calling it.

Finally, here’s Neil Gupta’s Safari extension for GMail. It adds the reading time estimate just above the GMail input field. It updates automatically as you type your message.

Neil did all the work on this. You can see the details at his GitHub repository.

OK, I think I’m done with reading time

1. Having the same key combo hasn’t caused a problem. In TextMate, the TM command governs; everywhere else, the Service is called. ↩︎