qutebrowser Fragments and Tips

Page contents

News

2020-May-07  qutebrowser v1.11.1 released. To keep up with qutebrowser releases, see github.com/qutebrowser/qutebrowser/releases, lists.schokokeks.org/pipermail/qutebrowser/, or old.reddit.com/r/qutebrowser/.

Prerequisites

This article assumes that you know the basics about the qutebrowser web browser. Some basics are discussed in Infinite Ink’s Getting Started with qutebrowser.

Editing config.py

To get the most flexibility configuring qutebrowser, I recommend that you use a config.py file. To learn about this file, including all possible settings, see Infinite Ink’s qutebrowser’s config.py.

You can edit config.py by doing the following within qutebrowser.

  1. Run the colon command :config-edit, which will open config.py in qutebrowser’s default editor.

  2. Edit the file, save your edits, and quit the editor. qutebrowser will automatically source the newly edited config.py.

👉️
To be able to use qutebrowser’s :config-edit command, you may need to specify c.editor.command. Examples of this are highlighted in the My settings section below.

 

Alternatively, you can do the following.

  1. Open congig.py in any plain text editor.

  2. Edit the file.

  3. Save your edits.

  4. Within qutebrowser run the colon command :config-source.

About key bindings

If you create a key binding, you may want to start it with a comma (,) because @The-Compiler (Florian Bruhin), qutebrowser’s main developer, has said that no default key binding will ever start with a comma.

To view all key bindings, run the following from within qutebrowser.

:bind

This lists both built-in and user-defined key bindings.

My settings

Here are some of my config.py settings. Note that a line that begins with a hash (#) is a comment and is ignored by qutebrowser.

The highlighted c.editor.command lines are useful for editing config.py, which is discussed in Editing config.py above.

c.content.default_encoding = 'utf-8'

c.content.geolocation = False

c.scrolling.bar = 'always'

c.tabs.background = True

c.zoom.default = '150%'

config.bind('<Ctrl-=>', 'zoom-in')

config.bind('<Ctrl-->', 'zoom-out')

## Next works on my Windows devices
c.editor.command = ['code.cmd', '-n', '{file}', '-w']

## Next works on my Windows devices (but is commented out for now)
# c.editor.command = ['gvim.bat', '-f', '{file}', '-c', 'normal {line}G{column0}l']

## I like my start page(s) and default page to be blank
c.url.start_pages = ["about:blank"]
c.url.default_page = "about:blank"

## I like to save web pages in MHTML format
## Thanks to the next key binding, I can use ,d to do that
config.bind(',d', 'set-cmd-text :download --mhtml')

## Next works on my Windows devices
c.downloads.location.directory = '%USERPROFILE%\\Downloads\\MHTML\\'

c.downloads.location.suggestion = 'both'

## ,ya is my shortcut to “yank asciidoc-formatted link”
config.bind(',ya', 'yank inline {url}[{title}]')

## ,ym is my shortcut to “yank markdown-formatted link”
## Alternatively, you can use `yank markdown` (which is deprecated)
config.bind(',ym', 'yank inline [{title}]({url})')

## next is a note to self about how to bind JavaScript code to a key shortcut
# config.bind(',hw', "jseval alert('Hello World')")

 

Variables

Variables can be used in the arguments of a qutebrowser command. Here is an excerpt from qutebrowser.org/doc/help/commands.html:

  • {url} expands to the URL of the current page

  • {url:pretty} expands to the URL in decoded format

  • {url:host}, {url:domain}, {url:auth}, {url:scheme}, {url:username}, {url:password}, {url:host}, {url:port}, {url:path} and {url:query} expand to the respective parts of the current URL

  • {title} expands to the current page’s title

  • {clipboard} expands to the clipboard contents

  • {primary} expands to the primary selection contents

 

JavaScript and the tsh command

qutebrowser’s default is:

c.content.javascript.enabled = True

If you want to surf the web without JavaScript, put the following in your config.py:

c.content.javascript.enabled = False

If you go to a website that you trust and want to turn on JavaScript, run the following command in qutebrowser:

tsh

This means toggle scripting for the current host during the current qutebrowser session. If you want to make this permanent for this host, use capital letter S, i.e.:

tSh

If you want to include subdomains of the current host, use capital letter H, i.e., one of the following.

tsH
tSH

Infinite Ink’s #qutebrowser Portal includes qutebrowser-related links from around the web, including:


Edit this page👍👎✍

To add a reaction or comment to this page, you need a GitHub account and your browser needs to be able to run a script that is hosted at https://utteranc.es.