cp ~/Library/Safari/History.db /tmp/h && sqlite3 /tmp/h "select json_object('items', json_group_array(json_object('quicklookurl', url, 'uid', title, 'title', title, 'arg', url))) as json_result from (select v.title, i.url, i.visit_count_score from history_items i join history_visits v on (v.history_item = i.id and v.title LIKE '%{query}%') group by v.title)"
cp -f ~/Library/Application\ Support/Google/Chrome/Default/History /tmp/ch
sqlite3 /tmp/ch "select json_object('items', json_group_array(json_object('quicklookurl', url, 'uid', title, 'title', title, 'arg', url))) as json_result from (SELECT url, title, visit_count FROM urls WHERE title LIKE '%{query}%' ORDER BY visit_count)"