Skip to content

Instantly share code, notes, and snippets.

@KevCui
Last active July 25, 2021 11:26
Show Gist options
  • Save KevCui/296a9fbd6d3726b65b5ebd053b2d9c9d to your computer and use it in GitHub Desktop.
Save KevCui/296a9fbd6d3726b65b5ebd053b2d9c9d to your computer and use it in GitHub Desktop.
A script applies Tridactyl configuration in seconds
#!/bin/bash
# Never heard of Tridctyl? Check this out https://addons.mozilla.org/en-US/firefox/addon/tridactyl-vim/
# This script can apply Tridactyl configuration in seconds:
# Step 1: Modify key bindings and string value in the variable "data" as json format.
# Step 2: ./update-tridactyl-conf.sh <path/storage-sync-v2.sqlite>
if [[ -z $(command -v sqlite3) ]]; then
echo "Command \"sqlite3\" does not exist!"
echo "Downlad: https://sqlite.org/download.html"
exit 1
fi
if [[ -z $1 ]]; then
echo "Missing path to storage-sync-v2.sqlite!"
echo "storage-sync-v2.sqilte can be found in \"<Profile folder>/firefox/<your profile>/storage-sync-v2.sqlite\""
echo "How to use:"
echo "~$ ./update-tridactyl-conf.sh <path/storage-sync-v2.sqilte>"
exit 1
fi
if [[ ! -f $1 ]]; then
echo "$1 does not exist!"
exit 1
fi
table_name="storage_sync_data"
ext_id="[email protected]"
date="$(date +%s)000"
# For more info about key binding and string value,
# visit https://github.com/cmcaine/tridactyl/blob/c2c5d2b/src/config.ts
data='
{
"userconfig": {
"configversion": "1.9",
"hintchars": "arstdhneio",
"inputmaps": {
"<C-w>": "text.backward_kill_word"
},
"nmaps": {
",": "back",
",p": null,
".": "forward",
"D": "composite tabclose | buffer #",
"H": "tabprev",
"L": "tabnext",
"ZZ": null,
"j": "scrollline -20",
"k": "scrollline 20",
"p": null,
"pp": "pin",
"<C-f>": null
},
"searchengine": "duckduckgo",
"searchurls": {
"g":"https://www.google.com/search?q=",
"gm":"https://www.google.de/maps/place/",
"m":"https://www.bing.com/maps/?q=",
"w":"http://www.wikipedia.org/w/index.php?title=Special:Search&search=",
"s":"https://www.startpage.com/do/dsearch?cat=web&pl=opensearch&language=english&query=",
"imdb":"http://www.imdb.com/find?s=all&q=",
"gi":"https://www.google.com/search?tbm=isch&q=",
"ut":"https://www.youtube.com/results?search_query="
},
"storageloc": "sync",
"theme": "dark",
"update": {
"lastchecktime": '"$date"'
}
}
}'
sqlite3 "$1" <<EOS
DELETE FROM $table_name WHERE ext_id="$ext_id";
INSERT INTO $table_name VALUES ('$ext_id', '$data', 1);
EOS
echo "DONE! Restart Firefox and have fun!"
@KevCui
Copy link
Author

KevCui commented Aug 11, 2020

This script is outdated, using ~/.tridactylrc configure file instead https://github.com/tridactyl/tridactyl/blob/master/.tridactylrc
To import configuration,native feature is required https://github.com/tridactyl/tridactyl#extra-features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment