Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created December 14, 2009 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/256421 to your computer and use it in GitHub Desktop.
Save tmcw/256421 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sqlite3'
# So this is address and name-completion for the sup mail client, which is
# really quite nice in a sort of vim-ish way
# However, I've switched since writing this, mainly because sup doesn't play nice with any other
# mail clients, so it screws up my read/unread/labeled systems when I'm using my iPhone, etc.
# Supposedly this is an upcoming feature, but it has been for a while and seems non-essential
# to the developers.
file_path = File.expand_path('~/Library/Application Support/AddressBook/AddressBook-v22.abcddb')
adbdb = SQLite3::Database.new(file_path)
contacts = adbdb.execute('select ZADDRESS, ZFIRSTNAME || " " || ZLASTNAME from ZABCDRECORD join ZABCDEMAILADDRESS on ZABCDEMAILADDRESS.ZOWNER = ZABCDRECORD.Z_PK')
contacts.map do |c|
"#{c[1]} <#{c[0]}>"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment