Skip to content

Instantly share code, notes, and snippets.

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 ijoseph/01c926e18c443be03f54e797d0a5f0bf to your computer and use it in GitHub Desktop.
Save ijoseph/01c926e18c443be03f54e797d0a5f0bf to your computer and use it in GitHub Desktop.
A script to copy Chrome's search engine settings into Vimium's settings format
#!/bin/sh
# This script lists user defined search engines in Chromium.
# It replaces {inputEncoding}, which appears in some search engine definitions, with
# UTF-8, {google:baseURL} with the Google URL, and omits other such tokens.
# Location of Chromium's 'Web Data' SQLite3 file
CHROMIUM_WEB_DATA="$HOME/.config/chromium/Default/Web Data"
# Location to create temporary copy of 'Web Data', since the database is locked while
# Chromium is running
COPY=$(mktemp)
cp "$CHROMIUM_WEB_DATA" "$COPY"
sqlite3 <<COMMANDS "$COPY" |
.mode list
.headers off
.echo off
.separator ':'
SELECT keyword ||": "|| url ||" "|| short_name FROM keywords;
.quit
COMMANDS
sed -e \ '
s#{searchTerms}#%s#g
s#{google:baseURL}#https://google.com/#g
s#{inputEncoding}#UTF-8#g
s#&?[^{}?&]\+={[^}]\+}##g
s#{[^}]\+}##g
'
rm "$COPY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment