TITLE: Converting Qutebrowser bookmarks to w3m bookmarks
DATE: 2018-12-01
AUTHOR: John L. Godlee
====================================================================
I use Qutebrowser as my primary web browser, but I also really like
using w3m for super fast text-based browsing when I'm working
mostly in the terminal. As a bit of practice in writing bash
scripts, I figured I would try to write a script which constructed
a w3m style bookmark.html from my Qutebrowser formatted
bookmarks/urls and quickmarks, because confusingly, Qutebrowser
uses two files for bookmarks, with different formatting. This is
what I came up with:
[Qutebrowser]: https://qutebrowser.org/
[w3m]: http://w3m.sourceforge.net/
#!/bin/bash
touch ~/.w3m/bookmark.html
echo "
Bookmarks
Quickmarks
" > ~/.w3m/bookmark.html
while read line; do
if [[ $line != *"qute"* ]]; then
url=$(echo $line | sed 's@.* @@')
desc=$(echo $line | sed 's/\(.*\) .*/\1/')
echo "- $desc" >>
~/.w3m/bookmark.html
fi
done < ~/.qutebrowser/quickmarks
echo "
" >> ~/.w3m/bookmark.html
echo "Other bookmarks
" >> ~/.w3m/bookmark.html
while read line; do
if [[ $line != *"qute"* ]]; then
url=$(echo $line | cut -d " " -f 1)
desc=$(echo ${line#* })
echo "- $desc" >>
~/.w3m/bookmark.html
fi
done < ~/.qutebrowser/bookmarks/urls
echo "
" >> ~/.w3m/bookmark.html
Firstly it creates a new bookmark.html, then echos some preamble
HTML, then loops through each line of quickmarks then urls, cutting
the line into the URL and the description of that URL, and forwards
it to bookmark.html, then it puts in the footer HTML material.
Importantly, it doesn't include any bookmarks with the string qute
in them, which all refer to Qutebrowser only special URIs, it does
this with an if statement if [[ $line != *"qute"* ]]; then.
In w3m, I can then open bookmark.html with Esc-b.
For the record, .qutebrowser/bookmarks/urls looks like this:
http://www.tablesgenerator.com/ Create LaTeX tables online
http://rbasicsworkshop.weebly.com/ R Basics Workshop - Home
http://app.uio.no/ifi/texcount/online.php TexCount
https://snazzymaps.com/ Snazzy Maps - Free Styles for Google
Maps
http://www.protectedplanet.net/ Protected Planet
while .qutebrowser/quickmarks looks like this:
Gmail https://mail.google.com/mail/u/0/h/
Google Keep https://keep.google.com/
Google Photos https://photos.google.com/
YouTube http://www.youtube.com/