Skip to content

Commit

Permalink
Allow passing the currently active kitty window id in the launch command
Browse files Browse the repository at this point in the history
See #2391
  • Loading branch information
kovidgoyal committed Feb 23, 2020
1 parent 82e5750 commit a82e45a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
11 changes: 11 additions & 0 deletions docs/launch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------

Expand Down
11 changes: 7 additions & 4 deletions kitty/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a82e45a

Please sign in to comment.