Use the Mac OS X Address Book with mutt

Oct 26, '04 10:08:00AM

Contributed by: bluehz

If you use the CLI mail client mutt, you can have it query your Mac OS X Address Book with a few simple steps:

  1. Download, compile and install The Little Brother's Database (lbdb)
  2. Modify the lbdb options
  3. Modify your mutt options to query lbdb
Read the rest of the hint for a detailed step-by-step guide...

Download and Install lbdb
Create the following script and make it executable (chmod +x script_name) to download, compile, and install the Little Brother's Database. Or you can do it yourself if you prefer...

#!/bin/sh

# This script will download the source code
# for lbdb, compile and install it in
# /usr/local/lbdb self-contained location.
#
# You must have Developer Tools installed to compile

# Download the source code
curl -O http://www.spinnaker.de/debian/lbdb_0.29.tar.gz
tar -zxvf lbdb_0.29.tar.gz
cd lbdb_0.29

# Configure, compile, and install
./configure --prefix=/usr/local/lbdb --libdir=/usr/local/lbdb/lib
sudo make install

# Move the man pages to a more friendly location
ln -s /usr/local/lbdb/man/man1/* /usr/local/man/man1/
Modify the lbdb Options:
You need to modify a few things in the lbdb configuration file. Open the config file with your favorite editor:
sudo pico /usr/local/lbdb/etc/lbdb.rc
Change this line (line 42):
# METHODS="m_inmail m_passwd m_finger"
To this:
METHODS="m_muttalias m_osx_addressbook"
and uncomment the following lines (line 67-68):
#MUTT_DIRECTORY="$HOME/.mutt"
#MUTTALIAS_FILES=".muttrc .mail_aliases muttrc aliases"
Modify Your Mutt Options:
Now you need to tell mutt to use lbdb to query the Mac OS X Address Book. Add the following line somewhere in your mutt options. For most people, that will probably be ~/.mutt/muttrc or ~/.mutt/options.
set query_command="/usr/local/lbdb/bin/lbdbq '%s'"
If you installed lbdb in a location other than as shown in Step 1 above, then alter the path as needed to point to the correct lbdb binary.

Thats it! Restart mutt. Now to use it, simply start addressing a new message, type a few characters of the name. Then type Control-T, and lbdb will query your mutt aliases file and your Mac OSX Address Book, looking for an approriate entry. Select an entry and continue with your message composition.

Note:

There are MANY more options available for lbdb, including harvesting addresses from incoming mail, using gnupg, ldap lookup, etc. If you need those functions, be sure to look at the man page for lbdbq and also the sources listed below.

Sources:
The Little Brother's Database (lbdb)
Mark's Mutt Fan and Tip page

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041024163030501