Allow using env vars that resolve to a full cmdline as program in launch mappings

Fixes #8613
This commit is contained in:
Kovid Goyal 2025-05-08 19:22:39 +05:30
parent 8a14a5638a
commit e0e4e53e3b
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 0 deletions

View file

@ -156,6 +156,8 @@ Detailed list of changes
- macOS: Fix text color in visual window select ignoring the color theme (:iss:`8579`)
- Launch action: Allow using an env var that resolves to a full command-line as the program to launch (:pull:`8613`)
0.41.1 [2025-04-03]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -141,6 +141,7 @@
platform_window_id,
safe_print,
sanitize_url_for_dispay_to_user,
shlex_split,
startup_notification_handler,
timed_debug_print,
which,
@ -2655,6 +2656,11 @@ def new_window_with_cwd(self, *args: str) -> None:
def launch(self, *args: str) -> None:
from kitty.launch import launch, parse_launch_args
opts, args_ = parse_launch_args(args)
if args_ and ' ' in args_[0]:
# this can happen for example with map f1 launch $EDITOR when $EDITOR is not a single command
q = which(args_[0])
if not q or (q is args_[0] and not os.access(q, os.X_OK)):
args_[:1] = shlex_split(args_[0])
if self.window_for_dispatch:
opts.source_window = opts.source_window or f'id:{self.window_for_dispatch.id}'
opts.next_to = opts.next_to or f'id:{self.window_for_dispatch.id}'