khard
Khard is an address book for the Unix command line. It can read, create, modify and delete vCard address book entries. Khard only works with a local store of vCard files. It is intended to be used in conjunction with other programs like an email client, text editor, vdir synchronizer or VOIP client.
Installation
- macOS
- iTerm2
brew install khardConfiguration
# example configuration file for khard version > 0.14.0
# place it under ~/.config/khard/khard.conf
# This file is parsed by the configobj library. The syntax is described at
# https://configobj.readthedocs.io/en/latest/configobj.html#the-config-file-format
[addressbooks]
[[family]]
path = ~/.contacts/family/
[[friends]]
path = ~/.contacts/friends/
[[work]]
path = ~/.contacts/work/
type = discover
[general]
debug = no
default_action = list
# These are either strings or comma seperated lists
# editor = vim, -i, NONE
editor = nvim
merge_editor = vimdiff
[contact table]
# display names by first or last name: first_name / last_name / formatted_name
display = first_name
# group by address book: yes / no
group_by_addressbook = no
# reverse table ordering: yes / no
reverse = no
# append nicknames to name column: yes / no
show_nicknames = no
# show uid table column: yes / no
show_uids = yes
# show kind table column: yes / no
show_kinds = no
# sort by first or last name: first_name / last_name / formatted_name
sort = last_name
# localize dates: yes / no
localize_dates = yes
# set a comma separated list of preferred phone number types in descending priority
# or nothing for non-filtered alphabetical order
preferred_phone_number_type = pref, cell, home
# set a comma separated list of preferred email address types in descending priority
# or nothing for non-filtered alphabetical order
preferred_email_address_type = pref, work, home
[vcard]
# extend contacts with your own private objects
# these objects are stored with a leading "X-" before the object name in the vcard files
# every object label may only contain letters, digits and the - character
# example:
# private_objects = Jabber, Skype, Twitter
# default: , (the empty list)
private_objects = Jabber, Skype, Twitter
# preferred vcard version: 3.0 / 4.0
preferred_version = 3.0
# Look into source vcf files to speed up search queries: yes / no
search_in_source_files = no
# skip unparsable vcard files: yes / no
skip_unparsable = noCommand line usage
Show contacts
khard listkhard list -a addressbook1,addressbook2khard showkhard show name_of_contact
Create contact
khard newkhard new [-a "address book name"]
Edit contacts
khard edit [-a addr_name] [search terms [search terms ...]]khard email -a work
Address book directories need to be created in advance, before you could reference them in the ~/.config/khard/khard.conf file.
Custom address templates
khard show stevenkhard postaddress steven
Both commands print the address of Steven, suitable for printing onto an envelope. But the current output format of the address only works nicely for some European countries, not for the US, not for the UK.
US address
Address:
home:
Box:
Extended:
Street: 567 E Evelyn Ave, Apt 1234
Code: 94041
City: Mountain View
Region: CA
Country: USACurrent khard output format (non American standard):
{Street}
{Extended}
{Code} {City}
{Region}, {Country}Address
home:
567 E Evelyn Ave
Apt 1234
94041 Mountain View
CA, USAStandard US address format:
{Street}
{City}
{Region} {Code}, {Country}Address
home:
567 E Evelyn Ave
Apt 1234
Mountain View
CA 94041, USAUK address
Example 1
Address:
home:
Box:
Extended:
Street: Unit 5, Hounslow Business Park, Alice Way
Code: TW3 3UD
City: Middlesex
Region:
Country: United KingdomCurrent khard output format (non British standard):
Address
home:
Unit 5, Hounslow Business Park, Alice Way
TW3 3UD Middlesex
United KingdomStandard UK address format:
{Street}
{City}, {Code}
{Country}Address
home:
Unit 5, Hounslow Business Park, Alice Way
Middlesex, TW3 3UD
United KingdomThere is not an established solution to this format problem, as custom address templates are currently unavailable for the users.
Workaround
khard show --format=yaml steven
--format possible choices: pretty, yaml, vcard, with default pretty. With the yaml format, it is easier to read as compared to the pretty format, which looks really odd for an standard American address.
Address :
home :
Box :
Extended :
Street :
Code :
City :
Region :
Country :