mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 02:02:14 +02:00
Remote control launch: Fix --env not implemented when using --cwd=current with the SSH kitten
Fixes #6438
This commit is contained in:
@@ -40,6 +40,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- macOS: Fix a regression that caused rendering to hang when transitioning to full screen with :opt:`macos_colorspace` set to ``default`` (:iss:`6435`)
|
- macOS: Fix a regression that caused rendering to hang when transitioning to full screen with :opt:`macos_colorspace` set to ``default`` (:iss:`6435`)
|
||||||
|
|
||||||
|
- Remote control launch: Fix ``--env`` not implemented when using ``--cwd=current`` with the SSH kitten (:iss:`6438`)
|
||||||
|
|
||||||
0.29.0 [2023-07-10]
|
0.29.0 [2023-07-10]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -148,9 +148,25 @@ def get_ssh_data(msg: str, request_id: str) -> Iterator[bytes]:
|
|||||||
yield b'KITTY_DATA_END\n'
|
yield b'KITTY_DATA_END\n'
|
||||||
|
|
||||||
|
|
||||||
def set_env_in_cmdline(env: Dict[str, str], argv: List[str]) -> None:
|
def set_env_in_cmdline(env: Dict[str, str], argv: List[str], clone: bool = True) -> None:
|
||||||
patch_cmdline('clone_env', create_shared_memory(env, 'ksse-'), argv)
|
from kitty.options.utils import DELETE_ENV_VAR
|
||||||
|
if clone:
|
||||||
|
patch_cmdline('clone_env', create_shared_memory(env, 'ksse-'), argv)
|
||||||
|
return
|
||||||
|
idx = argv.index('ssh')
|
||||||
|
for i in range(idx, len(argv)):
|
||||||
|
if argv[i] == '--kitten':
|
||||||
|
idx = i + 1
|
||||||
|
elif argv[i].startswith('--kitten='):
|
||||||
|
idx = i
|
||||||
|
env_dirs = []
|
||||||
|
for k, v in env.items():
|
||||||
|
if v is DELETE_ENV_VAR:
|
||||||
|
x = f'--kitten=env={k}'
|
||||||
|
else:
|
||||||
|
x = f'--kitten=env={k}={v}'
|
||||||
|
env_dirs.append(x)
|
||||||
|
argv[idx+1:idx+1] = env_dirs
|
||||||
|
|
||||||
|
|
||||||
def get_ssh_cli() -> Tuple[Set[str], Set[str]]:
|
def get_ssh_cli() -> Tuple[Set[str], Set[str]]:
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class Child:
|
|||||||
self.argv = list(argv)
|
self.argv = list(argv)
|
||||||
if cwd_from:
|
if cwd_from:
|
||||||
try:
|
try:
|
||||||
cwd = cwd_from.modify_argv_for_launch_with_cwd(self.argv) or cwd
|
cwd = cwd_from.modify_argv_for_launch_with_cwd(self.argv, env) or cwd
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log_error(f'Failed to read cwd of {cwd_from} with error: {err}')
|
log_error(f'Failed to read cwd of {cwd_from} with error: {err}')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class CwdRequest:
|
|||||||
return window.get_cwd_of_root_child() or ''
|
return window.get_cwd_of_root_child() or ''
|
||||||
return window.get_cwd_of_child(oldest=self.request_type is CwdRequestType.oldest) or ''
|
return window.get_cwd_of_child(oldest=self.request_type is CwdRequestType.oldest) or ''
|
||||||
|
|
||||||
def modify_argv_for_launch_with_cwd(self, argv: List[str]) -> str:
|
def modify_argv_for_launch_with_cwd(self, argv: List[str], env: Optional[Dict[str, str]]=None) -> str:
|
||||||
window = self.window
|
window = self.window
|
||||||
if not window:
|
if not window:
|
||||||
return ''
|
return ''
|
||||||
@@ -154,12 +154,14 @@ class CwdRequest:
|
|||||||
if ssh_kitten_cmdline:
|
if ssh_kitten_cmdline:
|
||||||
run_shell = argv[0] == resolved_shell(get_options())[0]
|
run_shell = argv[0] == resolved_shell(get_options())[0]
|
||||||
server_args = [] if run_shell else list(argv)
|
server_args = [] if run_shell else list(argv)
|
||||||
from kittens.ssh.utils import set_cwd_in_cmdline, set_server_args_in_cmdline
|
from kittens.ssh.utils import set_cwd_in_cmdline, set_env_in_cmdline, set_server_args_in_cmdline
|
||||||
argv[:] = ssh_kitten_cmdline
|
argv[:] = ssh_kitten_cmdline
|
||||||
if argv and argv[0] == 'kitten':
|
if argv and argv[0] == 'kitten':
|
||||||
argv[0] = kitten_exe()
|
argv[0] = kitten_exe()
|
||||||
set_cwd_in_cmdline(reported_cwd, argv)
|
set_cwd_in_cmdline(reported_cwd, argv)
|
||||||
set_server_args_in_cmdline(server_args, argv, allocate_tty=not run_shell)
|
set_server_args_in_cmdline(server_args, argv, allocate_tty=not run_shell)
|
||||||
|
if env is not None:
|
||||||
|
set_env_in_cmdline(env, argv, clone=False)
|
||||||
return ''
|
return ''
|
||||||
if not window.child_is_remote and (self.request_type is CwdRequestType.last_reported or window.at_prompt):
|
if not window.child_is_remote and (self.request_type is CwdRequestType.last_reported or window.at_prompt):
|
||||||
return reported_cwd
|
return reported_cwd
|
||||||
|
|||||||
Reference in New Issue
Block a user