Allow setting colors when creating windows using the launch command.

This commit is contained in:
Kovid Goyal 2021-01-31 12:13:27 +05:30
parent 2af145879e
commit ffc0919790
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 19 additions and 1 deletions

View File

@ -16,6 +16,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
slightly different from before. In particular watchers are now specified
directly on launch and env vars are set using ``--env``.
- Allow setting colors when creating windows using the :doc:`launch <launch>` command.
- diff kitten: Implement recursive diff over SSH (:iss:`3268`)
- ssh kitten: Allow using python instead of the shell on the server, useful if

View File

@ -11,7 +11,7 @@ from .child import Child
from .cli import WATCHER_DEFINITION, parse_args
from .cli_stub import LaunchCLIOptions
from .constants import resolve_custom_file
from .fast_data_types import set_clipboard_string
from .fast_data_types import patch_color_profiles, set_clipboard_string
from .tabs import Tab
from .utils import find_exe, read_shell_environment, set_primary_selection
from .window import Watchers, Window
@ -161,6 +161,13 @@ Set the WM_NAME property on X11 for the newly created OS Window when using
:option:`launch --type`=os-window. Defaults to :option:`launch --os-window-class`.
--color
type=list
Change colors in the newly launched window. You can either specify a path to a .conf
file with the same syntax as kitty.conf to read the colors from, or specify them
individually, for example: ``--color background=white`` ``--color foreground=red``
''' + WATCHER_DEFINITION
@ -239,6 +246,13 @@ class LaunchKwds(TypedDict):
stdin: Optional[bytes]
def apply_colors(window: Window, spec: Sequence[str]) -> None:
from kitty.rc.set_colors import parse_colors
colors, cursor_text_color = parse_colors(spec)
profiles = window.screen.color_profile,
patch_color_profiles(colors, cursor_text_color, profiles, True)
def launch(
boss: Boss,
opts: LaunchCLIOptions,
@ -329,6 +343,8 @@ def launch(
if tab is not None:
watchers = load_watch_modules(opts.watcher)
new_window: Window = tab.new_window(env=env or None, watchers=watchers or None, **kw)
if opts.color:
apply_colors(new_window, opts.color)
if opts.keep_focus and active:
boss.set_active_window(active, switch_os_window_if_needed=True)
return new_window