Part 2: A CRM on the command-line with abook, awk, grep and cut
A while ago, I posted https://yctct.com/abook-crm where I described how I use abook with tags, awk and grep altogether as a CRM.
The way I go about this has evolved. I still use tags with abook, but I no longer have a fixed script aliased to a command that I use to query abook’s file.
I use the following commands, which I recall from history, and tweak them depending on what I need.
For example, to output a list of URLs of contacts that match a specific tag, say, ‘agency’, I run:
$ awk 'BEGIN {RS = ""; FS = "\n"}/'"tag=agency"'/' ~/.abook/addressbook | grep url | cut -d '=' -f2
Or, to output a list of names of contacts that match a tag, say, ‘developer’, I use:
$ awk 'BEGIN {RS = ""; FS = "\n"}/'"tag=developer"'/' ~/.abook/addressbook | grep name | cut -d '=' -f2
When the output is too long, I pipe it to less.
If I need to open the websites of a few contacts, I grep the URLs from each contact and then pipe to vim:
$ awk 'BEGIN {RS = ""; FS = "\n"}/'"tag=agency"'/' ~/.abook/addressbook | grep url | cut -d '=' -f2 | vim -
Once I have a list of URLs in Vim, I can open each of the URLs with gx.
Also, to add contacts and email addressed I’ve added to .mail_aliases from Mutt, I merge the aliases’ file into abook from time to time, and then, clear duplicates with U in abook. I could probably try to automate this. Suggestions welcome.
personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki crm