kitty shell: show the previously active window id
This commit is contained in:
parent
d8896eb210
commit
0d704f3715
@ -942,19 +942,25 @@ class Boss:
|
|||||||
custom_callback=done, action_on_removal=done2)
|
custom_callback=done, action_on_removal=done2)
|
||||||
|
|
||||||
def kitty_shell(self, window_type: str) -> None:
|
def kitty_shell(self, window_type: str) -> None:
|
||||||
cmd = ['@', kitty_exe(), '@']
|
kw: Dict[str, Any] = {}
|
||||||
|
cmd = [kitty_exe(), '@']
|
||||||
|
aw = self.active_window
|
||||||
|
if aw is not None:
|
||||||
|
kw['env'] = {'KITTY_SHELL_ACTIVE_WINDOW_ID': str(aw.id)}
|
||||||
if window_type == 'tab':
|
if window_type == 'tab':
|
||||||
self._new_tab(cmd)
|
self._new_tab(SpecialWindow(cmd, **kw))
|
||||||
elif window_type == 'os_window':
|
elif window_type == 'os_window':
|
||||||
os_window_id = self._new_os_window(cmd)
|
os_window_id = self._new_os_window(SpecialWindow(cmd, **kw))
|
||||||
self.os_window_map[os_window_id]
|
self.os_window_map[os_window_id]
|
||||||
elif window_type == 'overlay':
|
elif window_type == 'overlay':
|
||||||
w = self.active_window
|
|
||||||
tab = self.active_tab
|
tab = self.active_tab
|
||||||
if w is not None and tab is not None:
|
if aw is not None and tab is not None:
|
||||||
tab.new_special_window(SpecialWindow(cmd, overlay_for=w.id))
|
kw['overlay_for'] = aw.id
|
||||||
|
tab.new_special_window(SpecialWindow(cmd, **kw))
|
||||||
else:
|
else:
|
||||||
self._new_window(cmd)
|
tab = self.active_tab
|
||||||
|
if tab is not None:
|
||||||
|
tab.new_special_window(SpecialWindow(cmd, **kw))
|
||||||
|
|
||||||
def switch_focus_to(self, window_id: int) -> None:
|
def switch_focus_to(self, window_id: int) -> None:
|
||||||
tab = self.active_tab
|
tab = self.active_tab
|
||||||
|
|||||||
@ -162,6 +162,9 @@ def real_main(global_opts: RCOptions) -> None:
|
|||||||
print_help_for_seq.allow_pager = False
|
print_help_for_seq.allow_pager = False
|
||||||
print('Welcome to the kitty shell!')
|
print('Welcome to the kitty shell!')
|
||||||
print('Use {} for assistance or {} to quit'.format(green('help'), green('exit')))
|
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('The ID of the previously active window is: {}'.format(awid))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user