launch: When using --cwd=current for a remote system support running non shell commands as well
This commit is contained in:
parent
244507336b
commit
7c8c7fe3a2
@ -42,6 +42,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Fix a regression in 0.27.0 that broke kitty @ set-font-size 0 (:iss:`5992`)
|
- Fix a regression in 0.27.0 that broke kitty @ set-font-size 0 (:iss:`5992`)
|
||||||
|
|
||||||
|
- launch: When using ``--cwd=current`` for a remote system support running non shell commands as well (:disc:`5987`)
|
||||||
|
|
||||||
|
|
||||||
0.27.1 [2023-02-07]
|
0.27.1 [2023-02-07]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@ -121,7 +121,11 @@ def is_extra_arg(arg: str, extra_args: Tuple[str, ...]) -> str:
|
|||||||
passthrough_args = {f'-{x}' for x in 'NnfGT'}
|
passthrough_args = {f'-{x}' for x in 'NnfGT'}
|
||||||
|
|
||||||
|
|
||||||
def set_server_args_in_cmdline(server_args: List[str], argv: List[str], extra_args: Tuple[str, ...] = ('--kitten',)) -> None:
|
def set_server_args_in_cmdline(
|
||||||
|
server_args: List[str], argv: List[str],
|
||||||
|
extra_args: Tuple[str, ...] = ('--kitten',),
|
||||||
|
allocate_tty: bool = False
|
||||||
|
) -> None:
|
||||||
boolean_ssh_args, other_ssh_args = get_ssh_cli()
|
boolean_ssh_args, other_ssh_args = get_ssh_cli()
|
||||||
ssh_args = []
|
ssh_args = []
|
||||||
expecting_option_val = False
|
expecting_option_val = False
|
||||||
@ -136,6 +140,8 @@ def set_server_args_in_cmdline(server_args: List[str], argv: List[str], extra_ar
|
|||||||
if argument.startswith('-') and not expecting_option_val:
|
if argument.startswith('-') and not expecting_option_val:
|
||||||
if argument == '--':
|
if argument == '--':
|
||||||
del ans[i+2:]
|
del ans[i+2:]
|
||||||
|
if allocate_tty and ans[i-1] != '-t':
|
||||||
|
ans.insert(i, '-t')
|
||||||
break
|
break
|
||||||
if extra_args:
|
if extra_args:
|
||||||
matching_ex = is_extra_arg(argument, extra_args)
|
matching_ex = is_extra_arg(argument, extra_args)
|
||||||
@ -173,5 +179,7 @@ def set_server_args_in_cmdline(server_args: List[str], argv: List[str], extra_ar
|
|||||||
expecting_option_val = False
|
expecting_option_val = False
|
||||||
continue
|
continue
|
||||||
del ans[i+1:]
|
del ans[i+1:]
|
||||||
|
if allocate_tty and ans[i] != '-t':
|
||||||
|
ans.insert(i, '-t')
|
||||||
break
|
break
|
||||||
argv[:] = ans + server_args
|
argv[:] = ans + server_args
|
||||||
|
|||||||
@ -432,6 +432,7 @@ def launch(
|
|||||||
force_target_tab: bool = False,
|
force_target_tab: bool = False,
|
||||||
active: Optional[Window] = None,
|
active: Optional[Window] = None,
|
||||||
is_clone_launch: str = '',
|
is_clone_launch: str = '',
|
||||||
|
rc_from_window: Optional[Window] = None,
|
||||||
) -> Optional[Window]:
|
) -> Optional[Window]:
|
||||||
active = active or boss.active_window_for_cwd
|
active = active or boss.active_window_for_cwd
|
||||||
if active:
|
if active:
|
||||||
@ -486,6 +487,8 @@ def launch(
|
|||||||
kw['cwd_from'] = CwdRequest(active, CwdRequestType.root)
|
kw['cwd_from'] = CwdRequest(active, CwdRequestType.root)
|
||||||
else:
|
else:
|
||||||
kw['cwd'] = opts.cwd
|
kw['cwd'] = opts.cwd
|
||||||
|
if kw['cwd_from'] is not None and rc_from_window is not None:
|
||||||
|
kw['cwd_from'].rc_from_window_id = rc_from_window.id
|
||||||
if opts.location != 'default':
|
if opts.location != 'default':
|
||||||
kw['location'] = opts.location
|
kw['location'] = opts.location
|
||||||
if opts.copy_colors and active:
|
if opts.copy_colors and active:
|
||||||
@ -538,9 +541,10 @@ def launch(
|
|||||||
elif x == '@last-line-on-screen':
|
elif x == '@last-line-on-screen':
|
||||||
x = str(screen.visual_line(screen.lines - 1) or '')
|
x = str(screen.visual_line(screen.lines - 1) or '')
|
||||||
final_cmd.append(x)
|
final_cmd.append(x)
|
||||||
exe = which(final_cmd[0])
|
if rc_from_window is None and final_cmd:
|
||||||
if exe:
|
exe = which(final_cmd[0])
|
||||||
final_cmd[0] = exe
|
if exe:
|
||||||
|
final_cmd[0] = exe
|
||||||
kw['cmd'] = final_cmd
|
kw['cmd'] = final_cmd
|
||||||
if force_window_launch and opts.type not in non_window_launch_types:
|
if force_window_launch and opts.type not in non_window_launch_types:
|
||||||
opts.type = 'window'
|
opts.type = 'window'
|
||||||
|
|||||||
@ -91,7 +91,7 @@ instead of the active tab
|
|||||||
target_tab = tabs[0]
|
target_tab = tabs[0]
|
||||||
elif payload_get('type') not in ('background', 'os-window', 'tab', 'window'):
|
elif payload_get('type') not in ('background', 'os-window', 'tab', 'window'):
|
||||||
return None
|
return None
|
||||||
w = do_launch(boss, opts, payload_get('args') or [], target_tab=target_tab)
|
w = do_launch(boss, opts, payload_get('args') or [], target_tab=target_tab, rc_from_window=window)
|
||||||
return None if payload_get('no_response') else str(getattr(w, 'id', 0))
|
return None if payload_get('no_response') else str(getattr(w, 'id', 0))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -144,6 +144,7 @@ class CwdRequest:
|
|||||||
def __init__(self, window: Optional['Window'] = None, request_type: CwdRequestType = CwdRequestType.current) -> None:
|
def __init__(self, window: Optional['Window'] = None, request_type: CwdRequestType = CwdRequestType.current) -> None:
|
||||||
self.window_id = -1 if window is None else window.id
|
self.window_id = -1 if window is None else window.id
|
||||||
self.request_type = request_type
|
self.request_type = request_type
|
||||||
|
self.rc_from_window_id = 0
|
||||||
|
|
||||||
def __bool__(self) -> bool:
|
def __bool__(self) -> bool:
|
||||||
return self.window_id > -1
|
return self.window_id > -1
|
||||||
@ -170,14 +171,15 @@ class CwdRequest:
|
|||||||
return ''
|
return ''
|
||||||
reported_cwd = path_from_osc7_url(window.screen.last_reported_cwd) if window.screen.last_reported_cwd else ''
|
reported_cwd = path_from_osc7_url(window.screen.last_reported_cwd) if window.screen.last_reported_cwd else ''
|
||||||
if reported_cwd and (self.request_type is not CwdRequestType.root or window.root_in_foreground_processes):
|
if reported_cwd and (self.request_type is not CwdRequestType.root or window.root_in_foreground_processes):
|
||||||
# First check if we are running ssh kitten, and trying to open the configured login shell
|
ssh_kitten_cmdline = window.ssh_kitten_cmdline()
|
||||||
if argv[0] == resolved_shell(get_options())[0]:
|
if ssh_kitten_cmdline:
|
||||||
ssh_kitten_cmdline = window.ssh_kitten_cmdline()
|
run_shell = argv[0] == resolved_shell(get_options())[0]
|
||||||
if ssh_kitten_cmdline:
|
server_args = [] if run_shell else list(argv)
|
||||||
from kittens.ssh.utils import set_cwd_in_cmdline
|
from kittens.ssh.utils import set_cwd_in_cmdline, set_server_args_in_cmdline
|
||||||
argv[:] = ssh_kitten_cmdline
|
argv[:] = ssh_kitten_cmdline
|
||||||
set_cwd_in_cmdline(reported_cwd, argv)
|
set_cwd_in_cmdline(reported_cwd, argv)
|
||||||
return ''
|
set_server_args_in_cmdline(server_args, argv, allocate_tty=not run_shell)
|
||||||
|
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
|
||||||
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 ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user