Created
December 14, 2009 21:04
-
-
Save tmcw/256421 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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