Compare commits
3 Commits
f8564f4b79
...
32727866bd
Author | SHA1 | Date | |
---|---|---|---|
32727866bd | |||
f9d5bc7764 | |||
2aa28fb2be |
4
programs
4
programs
@ -19,7 +19,7 @@ gimp
|
||||
blender
|
||||
audacity
|
||||
pulsemixer
|
||||
ffmppeg
|
||||
ffmpeg
|
||||
mpv
|
||||
netcat
|
||||
nmap
|
||||
@ -31,6 +31,8 @@ scrot
|
||||
pynvim
|
||||
python-lsp-server
|
||||
python-lsp-black
|
||||
typescript
|
||||
typescript-language-server
|
||||
bear
|
||||
xsel
|
||||
xwallpaper
|
||||
|
@ -45,6 +45,7 @@ end
|
||||
abbr -a -- gs git status
|
||||
abbr -a -- gl git log
|
||||
abbr -a -- gc git commit -S
|
||||
abbr -a -- ga git add
|
||||
abbr -a -- gca git commit -aS
|
||||
abbr -a -- gp git push
|
||||
abbr -a --position anywhere -- gh "&& git push gh"
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- Syntax highlighting
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = { "c", "cpp", "javascript", "python", "vim", "latex", "fish", "bash" },
|
||||
ensure_installed = { "c", "cpp", "javascript", "typescript", "python", "vim", "fish", "bash" },
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
highlight = {
|
||||
@ -65,6 +65,7 @@ local servers = {
|
||||
}
|
||||
},
|
||||
clangd = {},
|
||||
tsserver = {},
|
||||
}
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
@ -83,7 +83,7 @@ c.content.headers.custom = {"accept": "text/html,application/xhtml+xml,applicati
|
||||
# Sending a Do Not Track header makes your fingerprint more unique according to Panopticlick,
|
||||
# and I don't trust sites to respect it, so I think it's better to not include it at all.
|
||||
# (True: send DNT, False: Send DNT header set to 0, None: Don't send DNT)
|
||||
c.content.headers.do_not_track = None;
|
||||
c.content.headers.do_not_track = None
|
||||
|
||||
# Block certain trackers
|
||||
c.content.canvas_reading = False
|
||||
@ -95,3 +95,10 @@ config.bind("#", "set-cmd-text -s :scroll-to-anchor ")
|
||||
config.bind(";I", "hint images yank")
|
||||
# This overrides pP because I don't use primary clip
|
||||
config.bind("p", "open -t {clipboard}")
|
||||
|
||||
# code block copying
|
||||
c.hints.selectors["code"] = [
|
||||
":not(pre) > code",
|
||||
"pre"
|
||||
]
|
||||
config.bind("cc", "hint code userscript code_select.py")
|
||||
|
57
src/.local/share/qutebrowser/userscripts/code_select.py
Executable file
57
src/.local/share/qutebrowser/userscripts/code_select.py
Executable file
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import html
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
try:
|
||||
import pyperclip
|
||||
except ImportError:
|
||||
try:
|
||||
import pyclip as pyperclip
|
||||
except ImportError:
|
||||
PYPERCLIP = False
|
||||
else:
|
||||
PYPERCLIP = True
|
||||
else:
|
||||
PYPERCLIP = True
|
||||
|
||||
|
||||
def parse_text_content(element):
|
||||
root = ET.fromstring(element)
|
||||
text = ET.tostring(root, encoding="unicode", method="text")
|
||||
text = html.unescape(text)
|
||||
return text
|
||||
|
||||
|
||||
def send_command_to_qute(command):
|
||||
with open(os.environ.get("QUTE_FIFO"), "w") as f:
|
||||
f.write(command)
|
||||
|
||||
|
||||
def main():
|
||||
delimiter = sys.argv[1] if len(sys.argv) > 1 else ";"
|
||||
# For info on qute environment vairables, see
|
||||
# https://github.com/qutebrowser/qutebrowser/blob/master/doc/userscripts.asciidoc
|
||||
element = os.environ.get("QUTE_SELECTED_HTML")
|
||||
code_text = parse_text_content(element)
|
||||
if PYPERCLIP:
|
||||
pyperclip.copy(code_text)
|
||||
send_command_to_qute(
|
||||
"message-info 'copied to clipboard: {info}{suffix}'".format(
|
||||
info=code_text.splitlines()[0],
|
||||
suffix="..." if len(code_text.splitlines()) > 1 else ""
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Qute's yank command won't copy accross multiple lines so we
|
||||
# compromise by placing lines on a single line seperated by the
|
||||
# specified delimiter
|
||||
code_text = re.sub("(\n)+", delimiter, code_text)
|
||||
code_text = code_text.replace("'", "\"")
|
||||
send_command_to_qute("yank inline '{code}'\n".format(code=code_text))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user