Skip to content

Instantly share code, notes, and snippets.

@hijonathan
Created October 4, 2012 19:58
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hijonathan/3836026 to your computer and use it in GitHub Desktop.
Save hijonathan/3836026 to your computer and use it in GitHub Desktop.
Steps to transfer Chrome Custom Search Engines to Alfred

Step 0: Quit Chrome

Step 1: Get a dump of your search engines

> pwd
/Users/jonathankim/Desktop

> sqlite3 ~/Library/Application\ Support/Google/Chrome/Default/Web\ Data
sqlite3> .output chrome_export.sql
sqlite3> .dump keywords
sqlite3> .quit

Step 2: Grep through and find the search engine name, keyword and url string.

You're kind of on your own here...

Step 3: Create an array of settings objects

Again, you're on your own here...

Step 3: Use the sync script

Make sure to pass in your own search engine settings data from step 3.

from os import environ
from os.path import join
import shutil
import plistlib
PLIST_FILE_PATH = join(os.environ['HOME'], 'Library/Application Support/Alfred/customsites/customsites.plist')
custom_searches = [{
'name': 'Bing',
'keyword': 'bing.com',
'url': 'http://www.bing.com/search?setmkt=en-US&q={query}'
}, {
'name': 'TechCrunch',
'keyword': 'techcrunch.com',
'url': 'http://techcrunch.com/?s={query}'
}, {
'name': 'behance.net',
'keyword': 'behance.net',
'url': 'http://www.behance.net/?search={query}&header-search-content=projects'
}, {
'name': 'Flickr',
'keyword': 'flickr.com',
'url': 'http://www.flickr.com/search/?q={query}'
}, {
'name': 'Yelp',
'keyword': 'yelp.com',
'url': 'http://www.yelp.com/search?find_desc={query}&src=opensearch'
}, {
'name': 'Bottlenose',
'keyword': 'bottlenose.com',
'url': 'http://bottlenose.com/search/{query}'
}]
def get_plist_settings():
if len(custom_searches) <= 0:
return
plist_settings = []
for search in custom_searches:
data = {
'keyword': search['keyword'],
'spaces': False,
'text': search['name'],
'url': search['url'],
'utf8': False
}
plist_settings.append(data)
return plist_settings
def backup_plist_file(plist_file_path):
shutil.copyfile(plist_file_path, join(plist_file_path, '.bak'))
def write_plist_file(plist_settings, dest):
plistlib.writePlist(plist_settings, dest)
if __name__ == '__main__':
backup_plist_file(PLIST_FILE_PATH)
write_plist_file(get_plist_settings(), PLIST_FILE_PATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment