💾 Archived View for republic.circumlunar.space › users › johngodlee › posts › 2018-12-01-qute-w3m.gm… captured on 2024-02-05 at 10:38:42. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-04)

-=-=-=-=-=-=-

Converting Qutebrowser bookmarks to w3m bookmarks

DATE: 2018-12-01

AUTHOR: John L. Godlee

I use Qutebrowser[1] as my primary web browser, but I also really like using w3m[2] 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:

1: https://qutebrowser.org/

2: http://w3m.sourceforge.net/

#!/bin/bash

touch ~/.w3m/bookmark.html

echo "<html><head><title>Bookmarks</title></head>
<body>
<h1>Quickmarks</h1>
<ul>" > ~/.w3m/bookmark.html

while read line; do
    if [[ $line != *"qute"* ]]; then
        url=$(echo $line | sed 's@.* @@')
        desc=$(echo $line | sed 's/\(.*\) .*/\1/') 
        echo "<li><a href=\"$url\">$desc</a>" >> ~/.w3m/bookmark.html
    fi
done < ~/.qutebrowser/quickmarks 

echo "</ul>" >> ~/.w3m/bookmark.html

echo "<h1>Other bookmarks</h1>
<ul>" >> ~/.w3m/bookmark.html

while read line; do
    if [[ $line != *"qute"* ]]; then
        url=$(echo $line | cut -d " " -f 1) 
        desc=$(echo ${line#* }) 
        echo "<li><a href=\"$url\">$desc</a>" >> ~/.w3m/bookmark.html
    fi
done < ~/.qutebrowser/bookmarks/urls 

echo "</ul>
</body>
</html>" >> ~/.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/