From 896f93822df94d0f7dc5dafff382bcb0a1b79a87 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Oct 2022 08:52:35 +0530 Subject: [PATCH] kitty shell: Also output active tab id Fixes #5590 --- kitty/boss.py | 6 +++++- kitty/shell.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index bb4932016..96be98239 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1700,7 +1700,11 @@ class Boss: cmd = [kitty_exe(), '@'] aw = self.active_window if aw is not None: - kw['env'] = {'KITTY_SHELL_ACTIVE_WINDOW_ID': str(aw.id)} + env = {'KITTY_SHELL_ACTIVE_WINDOW_ID': str(aw.id)} + at = self.active_tab + if at is not None: + env['KITTY_SHELL_ACTIVE_TAB_ID'] = str(at.id) + kw['env'] = env if window_type == 'tab': tab = self._new_tab(SpecialWindow(cmd, **kw)) if tab is not None: diff --git a/kitty/shell.py b/kitty/shell.py index 0b5188e2e..a0a0d97db 100644 --- a/kitty/shell.py +++ b/kitty/shell.py @@ -185,7 +185,11 @@ def real_main(global_opts: RCOptions, encrypter: CommandEncrypter = NoEncryption print('Use {} for assistance or {} to quit'.format(green('help'), green('exit'))) awid = os.environ.pop('KITTY_SHELL_ACTIVE_WINDOW_ID', None) if awid is not None: - print(f'The ID of the previously active window is: {awid}') + atid = os.environ.pop('KITTY_SHELL_ACTIVE_TAB_ID', None) + am = f'Previously active window id: {awid}' + if atid is not None: + am += f' and tab id: {atid}' + print(am) pre_prompt = set_window_title('The kitty shell') + set_cursor_shape('bar') pre_prompt += f'\x1b]133;A;redraw={0 if is_libedit else 1}\x1b\\'