khard ownCloud Contacts for mutt

I use ownCloud to store my contacts and calendar, but until recently this has not been very useful when using mutt. My memory is not very good, and email address are hard; so I would have to either pull out my phone or open a web browser and find a contact. The setup was less than ideal.

Then I remember that vdirsyncer, the back-end for khal a tool I use for the caldav data also supported carddav downloads. I went to the documentation and found that vdirsyncer was pointing people to a tool called khard for use with the carddav data. So I configured vdirsyncer to download my contacts and went off to get khard working.

[storage my_contacts_local]
# A storage references actual data on a remote server or on the local disk.
# Similar to repositories in OfflineIMAP.
type = filesystem
path = ~/.contacts/
fileext = .vcf

[storage my_contacts_remote]
type = carddav
url = https://my.owncloud.url/remote.php/carddav/
#username =
#password =

A pip install (–user) later and it was ready to use. Like khal since the data is already on the computer the configuration as simple as pointing it to the contacts.

path = ~/.contacts/contacts/
editor = /usr/bin/emacsclient
default_country = USA

All that was left at that point was to tell mutt what my query_command was and I had my contacts list available from within mutt.

set query_command= "khard mutt --search '%s'"