Day 450
Kitty - the terminal emulator
Added bindsym $ms+Return exec ~/.local/kitty.app/bin/kitty
to ~/.config/i3/config
kitty - the fast, featureful, GPU based terminal emulator — kitty 0.17.1 documentation is really awesome actually, and noticeably faster than any other terminals I’ve used.
TODO - read through the documentation linked above, esp wrt zooming and config.
<Ctrl+Shift+F2> opens the config file. In general I love everything about Kitti for now, in all the tiny little details.
Changes:
font_family FiraCode-Bold
font_size 10.0
cursor_blink_interval 0.5
scrollback_lines 5000
strip_trailing_spaces smart
background_image ~/test.png
background_image_layout tiled
background_tint 0.7
Random / interesting
Waffle House Index - Wikipedia
If you get there and the Waffle House is closed? That’s really bad… — Craig Fugate, Former Head of the Federal Emergency Management Agency
Qutebrowser writing python userscripts
Just wrote this and put it into ~/.local/share/qutebrowser/userscripts/yank.py
.
This is an userscript that allows me to escape my only problematic markdown character (|
) when copying with ym
:
#!/usr/bin/python3
import os
title = os.environ['QUTE_TITLE']
title = title.replace("|", "\\|")
url = os.environ['QUTE_URL']
with open(os.environ['QUTE_FIFO'], 'w') as f:
f.write("yank inline \"[{}]({})\"".format(title, url))
Added config.bind('ym', 'spawn --userscript yank.py')
to config.py
Python set environment variables
Why did I need to use with open(..) as f:
in the above script and couldn’t just do os.environ['sth']='sth else'
?
Taskwarrior task annotation
It took seeing qutebrowser/taskadd at master · qutebrowser/qutebrowser to learn that you can annotate tasks in taskwarrior! task 123 annotate my annotation that can be long
adds a visible line with the annotation under the task that is shown whenever the task is shown. This is awesome and I should read manpages sometimes.
Keyboard layout
I should finally put it in order, especially given that I mostly don’t use the left-hand part of the left-hand typing layout, I started today by putting my ` and ~ no LALT+SHIFT+apostrophe by adding this:
key <AD01> { [ apostrophe,!quotedbl, grave, asciitilde] };
to /usr/share/X11/xkb/symbols/v4
Making Fiamma / Semantic Mediawiki alive again
{%raw%}{{=}}{%endraw%}
template
Using Template:= - Wikipedia as an example, I created a page located at = - Fiamma which I can include as {%raw%}{{=}}{%endraw%}
to replace URIs in parameters in my Template:B - Fiamma template. I’m not sure how would I edit all pages containing equal signs in parameters but this is a nice start. My source is Help:Template - Wikipedia, first bullet point.
Same works for |
, for which there’s already the default template {%raw%}{{!}}{%endraw%}
.
New javascript bookmarklets qutebrowser userscripts!
The old venerable bookmarklets I wrote about here Updated Fiamma “Add link” bookmarklet (now there are two of them!) | Я сам, соломка, чай. are as dead as it gets, I’ll write one userscript to rule them all :) Or one userscript and one vim script to expand it.
Current iteration is:
#!/usr/bin/python3
import os
from urllib.parse import quote_plus
def urlencode(string):
return quote_plus(string)
def replace(original):
new = original.replace("|", "-")
return new
title = os.environ['QUTE_TITLE']
url = os.environ['QUTE_URL']
newTitle = replace(title)
newUrl = replace(url)
et = urlencode(newTitle)
eu = urlencode(newUrl)
fiammaUrl = 'https://pchr8.net/f/index.php'
url = fiammaUrl+'?title='+et+'&action=edit&preload=Template:NewLink&preloadparams[]='+eu+'&preloadparams[]='+et
with open(os.environ['QUTE_FIFO'], 'w') as f:
f.write("open -w {}".format(url))
Pages to test this on:
- No Moods, Ads or Cutesy Fucking Icons » Phase-IV-4, containing an equal sign in the url
- Diensttagebuch | A purely technical blog about things I did on particular days, for future reference and search., containing a pipe in the title
Running userscript in qutebrowser
I had issues with commands executing too early, for example before the previous one has executed. So:
config.bind('B', 'spawn --userscript open_fiamma_page.py')
config.bind('T', 'hint inputs --first;; later 20 leave-mode;; later 20 open-editor')
Lastly for some reason the “later” sometimes are interpreted as starting at the same time, not from the time the last command finished executing.
Vim macros for the vimwin
(sorry)
{%raw%}
" let @H = 'gg??c??bi??c??b{{B|^[^[^[j0i|^[^[^[ji|j?kb^[^[^[ji|^[^[^[o}};q' " For the 5 lines
" let @L = 'ji{{$?kb%?kb#set:\^Mk=?kD^[o|+sep=,}}^[' " For the tags
" let @C = 'i[[C;tj?kb?kb?kbategory: ^[^[^[A]];q' " For each individual category
" let @F = 'jjVG:norm! @C\^M' "Apply that to all lines till the end
" let @d = '@H@L@F'
" let @q = '^[A^[bbbbbbi|??^B?kb^[:%s/=/{{=}}/ge^M'
" Summed up:
let @C = 'i[[C;tj?kb?kb?kbategory: ^[^[^[A]];q' " For each individual category
let @H = '^[A^[bbbbbbi|??^B?kb^[:%s/=/{{=}}/ge^Mgg??c??bi??c??b{{B|^[^[^[j0i|^[^[^[ji|j?kb^[^[^[ji|^[^[^[o}};qji{{$?kb%?kb#set:^Mk=?kD^[o|+sep=,}}^[jjVG:norm! @C^M:x^M'
" let @d = '@H@L@F'
{%endraw%}
The above changes text like:
https://www.pchr8.net/d/dtb/
Diensttagebuch - A purely technical blog about things I did on particular days, for future reference and search.
5
tag1, tag tag2, tag3
Cat1
Cat2
And a category with space
to
{%raw%}
{{B|https://www.pchr8.net/d/dtb/
|Diensttagebuch - A purely technical blog about things I did on particular days, for future reference and search.
|5
|6
}}
{{#set:
k=tag1, tag tag2, tag3
|+sep=, }}
[[Category: Cat1]]
[[Category: Cat2]]
[[Category: And a category with space]]
{%endraw%}
For the above, jekyll had issues with utf-8 encoding and the escaped characters, so I copy-pasted them with my mouse from my terminal.
Additionally it converts the equal sign to its template, and saves-and-closes gvim.
… And with the glorious new page Waffle House Index - Wikipedia - Fiamma a new era for that wiki starts again!
This raises the question about what is the role of this blog, but I think here we’ll stick to IT stuff
Vim script omit “Pattern not found” error
..especially when writing macros that replace stuff.
The magic is the e
option at the end:
:%s/x/y/ge
And the vim macro / script doesn’t break anymore.
DTB Master file
Added some things to the concat.sh
script, it’s even more ugly now but the resulting page is okay:
{% raw %}
echo "Concatting all existing days"
cd _posts
echo \
"---
layout: page
title: Master file
permalink: /master/
---
"\
> ../master_file.md
cat * | grep -v "layout: post" | grep -v "categories: \[" | grep -v "title: \"Day" | grep -v "date: 20" | grep -v "\-\-\-" >> ../master_file.md
{% endraw %}