diff --git a/kitty/boss.py b/kitty/boss.py index 421376e39..d60f92151 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -493,10 +493,12 @@ def _run_kitten(self, kitten, args=(), type_of_input='none'): raise ValueError('Unknown type_of_input: {}'.format(type_of_input)) from kittens.runner import create_kitten_handler end_kitten = create_kitten_handler(kitten, orig_args) + copts = {k: self.opts[k] for k in ('select_by_word_characters', 'open_url_with')} overlay_window = tab.new_special_window( SpecialWindow( ['kitty', '+runpy', 'from kittens.runner import main; main()'] + args, stdin=data, + env={'KITTY_COMMON_OPTS': json.dumps(copts)}, overlay_for=w.id)) overlay_window.action_on_close = partial(self.on_kitten_finish, w.id, end_kitten) diff --git a/kitty/tabs.py b/kitty/tabs.py index 6a3e3a378..339ed975e 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -21,11 +21,11 @@ from .window import Window, calculate_gl_geometry TabbarData = namedtuple('TabbarData', 'title is_active is_last') -SpecialWindowInstance = namedtuple('SpecialWindow', 'cmd stdin override_title cwd_from cwd overlay_for') +SpecialWindowInstance = namedtuple('SpecialWindow', 'cmd stdin override_title cwd_from cwd overlay_for env') -def SpecialWindow(cmd, stdin=None, override_title=None, cwd_from=None, cwd=None, overlay_for=None): - return SpecialWindowInstance(cmd, stdin, override_title, cwd_from, cwd, overlay_for) +def SpecialWindow(cmd, stdin=None, override_title=None, cwd_from=None, cwd=None, overlay_for=None, env=None): + return SpecialWindowInstance(cmd, stdin, override_title, cwd_from, cwd, overlay_for, env) class Tab: # {{{ @@ -124,25 +124,27 @@ def goto_layout(self, layout_name): self.current_layout = self.create_layout_object(layout_name) self.relayout() - def launch_child(self, use_shell=False, cmd=None, stdin=None, cwd_from=None, cwd=None): + def launch_child(self, use_shell=False, cmd=None, stdin=None, cwd_from=None, cwd=None, env=None): if cmd is None: if use_shell: cmd = resolved_shell(self.opts) else: cmd = self.args.args or resolved_shell(self.opts) - env = {} + fenv = {} + if env: + fenv.update(env) if not is_macos and not is_wayland: try: - env['WINDOWID'] = str(x11_window_id(self.os_window_id)) + fenv['WINDOWID'] = str(x11_window_id(self.os_window_id)) except Exception: import traceback traceback.print_exc() - ans = Child(cmd, cwd or self.cwd, self.opts, stdin, env, cwd_from) + ans = Child(cmd, cwd or self.cwd, self.opts, stdin, fenv, cwd_from) ans.fork() return ans - def new_window(self, use_shell=True, cmd=None, stdin=None, override_title=None, cwd_from=None, cwd=None, overlay_for=None): - child = self.launch_child(use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd) + def new_window(self, use_shell=True, cmd=None, stdin=None, override_title=None, cwd_from=None, cwd=None, overlay_for=None, env=None): + child = self.launch_child(use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd, env=env) window = Window(self, child, self.opts, self.args, override_title=override_title) if overlay_for is not None: overlaid = next(w for w in self.windows if w.id == overlay_for)