diff --git a/docs/changelog.rst b/docs/changelog.rst index 2aa28f77a..ebea1eaa8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -26,6 +26,9 @@ To update |kitty|, :doc:`follow the instructions `. - X11: Fix arrow mouse cursor using right pointing instead of the default left pointing arrow (:iss:`2341`) +- Allow passing the currently active kitty window id in the launch command + (:iss:`2391`) + - unicode input kitten: Allow pressing :kbd:`ctrl+tab` to change the input mode (:iss:`2343`) diff --git a/docs/launch.rst b/docs/launch.rst index f5c9d77f9..6f78b1a83 100644 --- a/docs/launch.rst +++ b/docs/launch.rst @@ -50,6 +50,17 @@ being the top left corner and ``{lines},{columns}`` being the number of rows and columns of the screen. +Special arguments +------------------- + +There are a few special placeholder arguments that can be specified as part of +the command line. Namely ``@selection`` which is replaced by the current +selection and ``@kitty_active_window_id`` which is replaced by the id of the +currently active kitty window. For example:: + + map f1 launch my-program @kitty-active-window-id + + Syntax reference ------------------ diff --git a/kitty/launch.py b/kitty/launch.py index 765ce107e..dfb87c8f1 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -193,10 +193,13 @@ def launch(boss, opts, args, target_tab=None): if cmd: final_cmd = [] for x in cmd: - if x == '@selection' and active and not opts.copy_cmdline: - s = boss.data_for_at(active, x) - if s: - x = s + if active and not opts.copy_cmdline: + if x == '@selection': + s = boss.data_for_at(active, x) + if s: + x = s + elif x == '@active-kitty-window-id': + x = str(active.id) final_cmd.append(x) kw['cmd'] = final_cmd if opts.type == 'overlay' and active and not active.overlay_window_id: