From e0e4e53e3bc8851bcbe800c01d3eaa3578384d53 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 8 May 2025 19:22:39 +0530 Subject: [PATCH] Allow using env vars that resolve to a full cmdline as program in launch mappings Fixes #8613 --- docs/changelog.rst | 2 ++ kitty/boss.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 521f86c1a..a8480a5ba 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/boss.py b/kitty/boss.py index 96aff216c..ef0b482df 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -141,6 +141,7 @@ from .utils import ( platform_window_id, safe_print, sanitize_url_for_dispay_to_user, + shlex_split, startup_notification_handler, timed_debug_print, which, @@ -2655,6 +2656,11 @@ class Boss: 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}'