Fix lbdb and abook on macOS
I have been using mutt to handle my work emails and liking it. In combination with mutt, I also make use of abook which is a simple address book. To query abook and other contact sources (e.g., past emails), I use lbdb. A query to lbdb queries each of the individual sources and returns a combined list of results. This works fine, except for a small bug on macOS: the name of abook entries comes back incomplete and with “abook” appended.
At the heart of the issue is the different functionality between GNU sed
(present on your average “GNU/Linux” machine) and BSD sed present on macOS.
Specifically, lbdb makes use of a sed call with some regex containing \t
. In
GNU sed this signifies a tab character. It does not, however, work on BSD sed.
Fixing it can be done by editing the shell script lbdb uses to query abook. If
you installed lbdb via Homebrew, then the script in question can be found at
/usr/local/Cellar/lbdb/0.44/lib/lbdb/m_abook
. If you installed it through
some other means, you will have to find the location yourself. In the path I
give, the 0.44
is obviously the version number. If you are using a different
version, use the appropriate number there. Note that by the nature of how I fix
it here, you will have to apply the fix again for a new version of abook.
Locate the following lines:
$ABOOK --datafile $book --mutt-query "$@" \
| sed -e '1d;s/\([^\t]*\t[^\t]*\).*/\1\tabook/'
and change them to
$ABOOK --datafile $book --mutt-query "$@" \
| sed -e '1d;s/$/ (abook)/'
Now the names in your results should be correct again. The (abook)
mention is
just added to the end of the description.