mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Preserve env vars from onvoking env when creating new os window via single instance
This commit is contained in:
@@ -128,6 +128,9 @@ Detailed list of changes
|
||||
- Fix a regression in 0.36.0 that caused using = with single letter options to
|
||||
no longer work correctly (:iss:`8556`)
|
||||
|
||||
- Single instance: Preserve environment variables from invoking environment in
|
||||
newly created window (:disc:`8567`)
|
||||
|
||||
|
||||
0.41.1 [2025-04-03]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -870,8 +870,10 @@ class Boss:
|
||||
args.session = ''
|
||||
if not os.path.isabs(args.directory):
|
||||
args.directory = os.path.join(data['cwd'], args.directory)
|
||||
from .child import process_env
|
||||
clean_env = process_env(data['environ'])
|
||||
focused_os_window = os_window_id = 0
|
||||
for session in create_sessions(opts, args, respect_cwd=True):
|
||||
for session in create_sessions(opts, args, respect_cwd=True, env_when_no_session=clean_env):
|
||||
if not session.has_non_background_processes:
|
||||
# background only do not create an OS Window
|
||||
from .launch import LaunchSpec, launch
|
||||
|
||||
@@ -145,8 +145,8 @@ def environ_of_process(pid: int) -> dict[str, str]:
|
||||
return parse_environ_block(_environ_of_process(pid))
|
||||
|
||||
|
||||
def process_env() -> dict[str, str]:
|
||||
ans = dict(os.environ)
|
||||
def process_env(env: dict[str, str] | None = None) -> dict[str, str]:
|
||||
ans = dict(os.environ if env is None else env)
|
||||
ssl_env_var = getattr(sys, 'kitty_ssl_env_var', None)
|
||||
if ssl_env_var is not None:
|
||||
ans.pop(ssl_env_var, None)
|
||||
|
||||
@@ -241,6 +241,7 @@ def create_sessions(
|
||||
cwd_from: Optional['CwdRequest'] = None,
|
||||
respect_cwd: bool = False,
|
||||
default_session: str | None = None,
|
||||
env_when_no_session: dict[str, str] | None = None,
|
||||
) -> Iterator[Session]:
|
||||
if args and args.session:
|
||||
if args.session == "none":
|
||||
@@ -276,6 +277,6 @@ def create_sessions(
|
||||
cmd = args.args if args and args.args else resolved_shell(opts)
|
||||
from kitty.tabs import SpecialWindow
|
||||
cwd: str | None = args.directory if respect_cwd and args else None
|
||||
special_window = SpecialWindow(cmd, cwd_from=cwd_from, cwd=cwd, hold=bool(args and args.hold))
|
||||
special_window = SpecialWindow(cmd, cwd_from=cwd_from, cwd=cwd, env=env_when_no_session, hold=bool(args and args.hold))
|
||||
ans.add_special_window(special_window)
|
||||
yield ans
|
||||
|
||||
Reference in New Issue
Block a user