|Version 2 (modified by rado, 22 months ago) (diff)|
Did you ever feel the need for some addressbook "better" than mutt's internal alias management?
By setting <tt>$query_command</tt> in your .muttrc you can tell mutt to use an external program for looking up addresses when invoking the "Query" command (hit '?' for mutt-keybinding). <tt>query_command</tt> is used as well for address completion in any prompt for address entry, default by hitting T.
Selecting multiple lines in query menu
The query command can return multiple addresses. If you want to select multiple addresses it does not work if you tag them with 't' and then hit <tt>return</tt>. What works for me is pressing <tt>;-m</tt>.
Different tools for queries
- http://www.bsdconsulting.no/tools/ -- mutt-ldap.pl
- Query Active Directory & Exchange for mail addresses using LDAP.
- http://abook.sourceforge.net/ -- Jaakko Heinonen
- http://home.uchicago.edu/~dgc/mutt/#qi -- David Champion (dgc)
- mutt-phquery -- directory lookups in Qi
- http://www.spinnaker.de/lbdb/ -- The Little Brother's Database is capable of extracting addresses from various sources including messages fed individually by a MDA or bulk fed, for example in the way described at http://serendipity.ruwenzori.net/index.php/2006/02/25/feeding-whole-maildirs-to-lbdb-for-mutts-address-completion
- http://shove-it.de/open/jcm/muttquery.py --
- I searched the web to find a query program to query the kde-addressbook. I use kaddressbook because it eases the use of my palm. This script just reads the std.vcf file. No need of addressbook-conversion. Please write here any improvement wishes. It is not testet well til now, just wrote it and it seems to work anyhow.
- QueryCommand/MuttLdapSearch -- Search LDAP directory using only ldapsearch and SH commands.
- Use this if you want a query_command for LDAP with as few requirements as possible. Just copy and paste into your favorite text editor (be sure to check the lines ending in '\' to make sure there are no extraneous spaces at the end) and save as 'mutt_ldap_search.sh' or whatever you prefer. Be sure to make it executable (chmod a+x mutt_ldap_search.sh) and add an appropriate query_command line to your .muttrc file.
- http://gromnizki.unixdev.net/etc/mutt_openldap.tcl -- \
Yet another way to search LDAP directory. Requires <b>Tcl</b> http://tcl.tk \
and <b>ldapsearch</b> http://openldap.org. Some script advantages:
- UTF-8 support.
- Easy search mode (automatically match <i>mail</i>, <i>cn</i>, \ <i>sn</i> and <i>givenName</i> attributes).
- Automatically recognizes LDAP search filter mode (i.e. write \ something like "(cn=john*)" (with double quotes!) to use it).
- Display attributes (except <i>mail</i> and <i>cn</i>) in user order.
- Size limit support.
- QueryCommand/EvolutionSearch -- Search the Ximian Evolution 2 address book.
- Use this if you want a query_command for searching your Evolution address book. It has not been extensively tested but is simple and should be easy to customise.
- Gmail contact search
- http://harward.us/~nharward/mabs.zip -- Mac Address Book Search (universal binary). The source code needs a few enhancements for non-mutt users as a general utility and then will be published.
- http://sourceforge.net/projects/abtomutt/files/ -- Address Book to Mutt (MacOS X)
- This program's sole function is to perform lookups in the MacOS X Address Book and feed the results to the terminal in a format that Mutt can understand for e-mail address queries and e-mail address completion.
Using Multiple Query Tools
The above tools are great if all your addresses are in one place, but what if you've got multiple sources to search? (My need for a solution for this came from having to search the corporate LDAP directory and abook's records.)
Fortunately, many *nix distributions (Debian, Redhat both confirmed) come with the perfect tool for combining these resources. Additionally, this method can be used with the majority of the tools listed above and with most stand-alone scripts written for mutt on the interwubs:
user@myhost:~/.mutt/address-providers$ pwd /home/user/.mutt/address-providers user@myhost:~/.mutt/address-providers$ ls -l total 8 -rwx------ 1 user user 127 2008-04-16 22:43 dummy_addresses -rwx------ 1 user user 1708 2008-04-16 18:58 mutt_ldap user@myhost:~/.mutt/address-providers$ cat dummy_addresses #!/bin/bash echo "firstname.lastname@example.org buuuuuuuuuh HELLOOOOOOOOOOOOOOO" echo "email@example.com Roger Smith Properly Formed Entry" user@myhost:~/.mutt/address-providers$ grep query ~/.muttrc set query_command = "echo ; /bin/run-parts -a '%s' /home/user/.mutt/address-providers/|grep '@'"
To add a new search mechanism, just drop the file into the address-providers directory. Each script in address-providers should
- be executable
- have a name containing only these characters: [a-zA-Z0-9-_]
- take a query as its first parameter
As a result of (2), to stop any script from being used just pop a period in its name: "mv Broken_Script Broken_Script.bother"
NB1 In my example, the "dummy_addresses" provider is there simply to prove to yourself that the mechanism is working. Remove it after testing.
NB2 A couple of points about the query_command:
- The initial "echo;" is there because mutt doesn't use or display the first line as a potential address; it doesn't seem to be used anywhere with my fairly stock mutt install, but that doesn't mean it's useless. Change the echo statement to output anything you want
- The final "grep '@'" is a nasty way of removing each script's initial reporting line that mutt would normally remove itself, as per point (1). It works as long as you're only looking for addresses that definitely use @'s, and you don't need each script's reporting line, and no reporting line contains an @. For most people, none of this is a problem - just use it as is. If you've got a problem with this, then you probably know enough to alter the command to achieve what you want ... -- jaycee