mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Script to add shortcut definitions to readme
This commit is contained in:
27
preprocess-readme.py
Executable file
27
preprocess-readme.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(base)
|
||||
|
||||
|
||||
defns = []
|
||||
|
||||
for line in open('kitty/kitty.conf'):
|
||||
if line.startswith('map '):
|
||||
_, sc, name = line.split(maxsplit=3)
|
||||
defns.append(':sc_{}: `{}`'.format(name, sc))
|
||||
|
||||
defns = '\n'.join(defns)
|
||||
|
||||
raw = open('README.asciidoc').read()
|
||||
pat = re.compile(r'^// START_SHORTCUT_BLOCK$.+?^// END_SHORTCUT_BLOCK$', re.M | re.DOTALL)
|
||||
nraw = pat.sub('// START_SHORTCUT_BLOCK\n' +
|
||||
defns + '\n// END_SHORTCUT_BLOCK', raw)
|
||||
if raw != nraw:
|
||||
print('Updating shortcuts block')
|
||||
open('README.asciidoc', 'w').write(nraw)
|
||||
Reference in New Issue
Block a user