Allow passing the currently active kitty window id in the launch command

See #2391
This commit is contained in:
Kovid Goyal 2020-02-23 19:17:26 +05:30
parent 82e5750d71
commit a82e45ad71
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 21 additions and 4 deletions

View File

@ -26,6 +26,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- 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`)

View File

@ -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
------------------

View File

@ -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: