One of the ways you can really Get Things Done is to minimize or eliminate distractions. The most prevalent and dangerous distraction is e-mail. People leave their e-mail clients open all day, and some even have them set to automatically check their mail every minute! And, when new mail is found, the client will pop-up and play a sound — who needs that many distractions? No wonder people are doing less and less with their day, they can get interrupted dozens or even hundreds of times each day!
There are lots of tips on how to break this chain floating around on the ‘net, among them:
And that’s just dealing with the processing of new mail. There’s much ranting to do about people with dozens of mail in their inbox, some dating back months, but that’s another show.
I’ve taken a different approach to my mail. I use mutt as my mail client, which I realize makes me different already. But I’ve written a script to force me to check my mail no more than once per hour. Here it is:
#!/bin/sh
# checkmail -- shell script to check mail no more than once per hour
# eric Farris <eafarris@gmail.com>, 2005
LASTRUN=$(<$HOME/Library/ScriptSupport/checkmail.lastrun)
if [ "$LASTRUN" == "`date '+%D %H'`" ]
then
echo Already ran this hour. Try again after $((`date +%k` + 1)):00
else
if [ "$((`date +%k` % 4))" == "0" ]
then
$HOME/Library/Scripts/fetchyahoo
else
echo Only checking Yahoo! mail every four hours.
fi
fetchmail -a && date '+%D %H' > $HOME/Library/ScriptSupport/checkmail.lastrun
sleep 2
mutt -z && clear
fi
While teaching bash scripting is quite a bit outside the scope of this article (even this site), and there’s no guarantee I’m doing this right, here’s some notes about that script.
The magic is the checkmail.lastrun file. In it will be the date and hour the script was last run. This file is read into the $LASTRUN variable, where it will be checked against the current date and hour. If they’re not the same, the script will do a mail check.
Then the date modulo 4 is compared. If the hour is a multiple of four, the script will run the fetchyahoo script, which picks up the mail from my Yahoo! account (which gets forwarded by the script to my Gmail account).
If we’ve made it this far, it’s time to check the mail. This happens with a call to fetchmail, then conditionally the current date and hour is written to the lastrun file, for the next time.
The script then pauses two seconds, to give my Powerbook time to get the mail delivered. If there’s a lot of mail that fetchmail downloaded, it may take more than two seconds, but I’ve found that if I wait a few seconds, postfix can handle most of the delivery.
Then mutt is called with the -z switch. The -z will exit mutt immediately if there’s no mail. I regularly keep my inbox empty, using the GTD rule that “anything in an inbox is either trash (throw it away), reference (file it away), or action (put it on a list).” Mail just doesn’t sit in my inbox, so many times the ‘mutt -z’ command just tells me the good news that there isn’t any mail and gets me back to the command prompt.
I suppose I could make the minute that fetchmail was run significant, which would force 60 minutes between calls. As it is now, I can check my mail at both 14:59 and 15:00, but then not again until the clock turns 16:00 (or later).
Anyway, that’s the script. No big deal, I suppose, but, I’ve documented it.