beforeRunningCommand nop bundleUUID B7BC3FFD-6E4B-11D9-91AF-000D93589AF6 command #!/usr/bin/env ruby -wKU SUPPORT = ENV['TM_SUPPORT_PATH'] DIALOG = SUPPORT + '/bin/tm_dialog' require SUPPORT + '/lib/escape' require SUPPORT + '/lib/plist' require SUPPORT + '/lib/exit_codes' search_text = STDIN.read names = [] data = %x{contacts -HSs -f "%n:%e:" "#{search_text}"} data.scan(/(.*)?:(.*)?:/){|name,email| if !email.empty? names << { 'title' => "#{name} (#{email})", 'email' => "#{name} <#{email}>" } end } TextMate.exit_show_tool_tip "No matches found" if names.empty? TextMate.exit_replace_text names[0]['email'] if names.length == 1 plist = { 'menuItems' => names }.to_plist res = PropertyList::load(`#{e_sh DIALOG} -up #{e_sh plist}`) TextMate.exit_replace_text(search_text) unless res.has_key? 'selectedMenuItem' print res['selectedMenuItem']['email'] fallbackInput word input selection keyEquivalent ^@A name Find Email Address in Address Book output replaceSelectedText uuid 575C4CAF-71B1-4F92-886B-8D89E0D0EFDD