Allow changing colors by mapping a keyboard shortcut to read a kitty config file with color definitions.

Fixes #2083
This commit is contained in:
Kovid Goyal 2019-10-21 14:43:35 +05:30
parent d33c287344
commit d92f8a90ef
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 26 additions and 2 deletions

View File

@ -9,6 +9,10 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Add a new style ``powerline`` for tab bar rendering, see :opt:`tab_bar_style` (:pull:`2021`)
- Allow changing colors by mapping a keyboard shortcut to read a kitty config
file with color definitions. See the :doc:`FAQ <faq>` for details
(:iss:`2083`)
- Wayland: Fix key repeat not being stopped when focus leaves window. This is
expected behavior on Wayland, apparently (:iss:`2014`)

View File

@ -109,8 +109,13 @@ How do I change the colors in a running kitty instance?
You can either use the
`OSC terminal escape codes <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands>`_
to set colors or you can enable :doc:`remote control <remote-control>`
for |kitty| and use :ref:`at_set-colors`.
to set colors or you can define keyboard shortcuts to set colors, for example::
map f1 set_colors --configured /path/to/some/config/file/colors.conf
Or you can enable :doc:`remote control <remote-control>` for |kitty| and use :ref:`at_set-colors`.
The shortcut mapping technique has the same syntax as the remote control
command, for details, see :ref:`at_set-colors`.
A list of pre-made color themes for kitty is available at:
`kitty-themes <https://github.com/dexpota/kitty-themes>`_

View File

@ -1096,3 +1096,9 @@ class Boss:
msg = '\n'.join(map(format_bad_line, bad_lines)).rstrip()
self.show_error(_('Errors in kitty.conf'), msg)
def set_colors(self, *args):
from .cmds import parse_subcommand_cli, cmd_set_colors, set_colors
opts, items = parse_subcommand_cli(cmd_set_colors, ['set-colors'] + list(args))
payload = cmd_set_colors(None, opts, items)
set_colors(self, self.active_window, payload)

View File

@ -193,6 +193,15 @@ def pipe(func, rest):
return func, rest
@func_with_args('set_colors')
def set_colors(func, rest):
import shlex
rest = shlex.split(rest)
if len(rest) < 1:
log_error('Too few arguments to set_colors function')
return func, rest
@func_with_args('nth_window')
def nth_window(func, rest):
try: