Go to file
2024-09-01 13:05:53 +01:00
.gitignore Initial commit with existing userscript. 2019-07-23 14:53:03 +01:00
code_select.py feat: remove lines starting with dollar sign (#4) 2024-09-01 13:05:53 +01:00
README.md Update documentation 2024-01-14 14:31:40 +00:00

Qute Code Hint

A small qutebrowser userscript for copying code snippets on web pages to the clipboard.

Example

Hinting: Hinting

Copying to clipboard: Copying

Installation

  1. Download the script:
wget https://raw.githubusercontent.com/LaurenceWarne/qute-code-hint/master/code_select.py -O ~/.local/share/qutebrowser/userscripts/code_select.py
  1. In your qutebrowser config file create a new custom group for code:
c.hints.selectors["code"] = [
    # Selects all code tags whose direct parent is not a pre tag
    ":not(pre) > code",
    "pre"
]
  1. Bind the userscript using a keybinding of your choice:
...
'<ctrl-#>': 'hint code userscript code_select.py',
...
  1. Optionally install the python pyperclip module for better multiline copying:
pip3 install pyperclip --user
# Alternatively for PEP 668 compliance, you can install from your package manager, e.g.
sudo apt install python3-pyperclip

If you're having issues with pyperclip, you can use pyclip instead:

pip3 install pyclip

Multiline Copying

Without pyperclip/pyclip the default behaviour for code snippets spanning multiple lines is to join them all on one line, with semicolons separating the previously seperate lines.