diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index 438c8e88e..fb6523c36 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -17,7 +17,6 @@ from typing import ( ) from kitty.constants import cache_dir, shell_integration_dir, terminfo_dir -from kitty.shell_integration import get_effective_ksi_env_var from kitty.short_uuid import uuid4 from kitty.types import run_once from kitty.utils import SSHConnectionData @@ -52,7 +51,13 @@ def make_tarfile(ssh_opts: SSHOptions) -> bytes: buf = io.BytesIO() with tarfile.open(mode='w:bz2', fileobj=buf, encoding='utf-8') as tf: rd = ssh_opts.remote_dir.rstrip('/') - ksi = get_effective_ksi_env_var() + from kitty.shell_integration import get_effective_ksi_env_var + if ssh_opts.shell_integration == 'inherit': + ksi = get_effective_ksi_env_var() + else: + from kitty.options.types import Options + from kitty.options.utils import shell_integration + ksi = get_effective_ksi_env_var(Options({'shell_integration': shell_integration(ssh_opts.shell_integration)})) if ksi: tf.add(shell_integration_dir, arcname=rd + '/shell-integration', filter=filter_files) add_data_as_file(tf, rd + '/settings/ksi_env_var', ksi) diff --git a/kittens/ssh/options/definition.py b/kittens/ssh/options/definition.py index 08d44bab0..23dfb70c5 100644 --- a/kittens/ssh/options/definition.py +++ b/kittens/ssh/options/definition.py @@ -24,14 +24,18 @@ hosts can be used. When not specified options apply to all hosts, until the first hostname specification is found. Note that the hostname this matches against is the hostname used by the remote computer, not the name you pass to SSH to connect to it. -''' - ) +''') opt('remote_dir', '.local/share/kitty-ssh-kitten', long_text=''' The location on the remote computer where the files needed for this kitten are installed. The location is relative to the HOME directory. -''' - ) +''') + +opt('shell_integration', 'inherit', long_text=''' +Control the shell integration on the remote host. See ref:`shell_integration` +for details on how this setting works. The special value :code:`inherit` means +use the setting from kitty.conf. This setting is mainly useful for overriding +integration on a per-host basis.''') opt('+env', '', option_type='env', add_to_default=False, long_text=''' Specify environment variables to set on the remote host. Note that diff --git a/kittens/ssh/options/parse.py b/kittens/ssh/options/parse.py index aba3c82d2..dbd789b97 100644 --- a/kittens/ssh/options/parse.py +++ b/kittens/ssh/options/parse.py @@ -17,6 +17,9 @@ class Parser: def remote_dir(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: ans['remote_dir'] = str(val) + def shell_integration(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: + ans['shell_integration'] = str(val) + def create_result_dict() -> typing.Dict[str, typing.Any]: return { diff --git a/kittens/ssh/options/types.py b/kittens/ssh/options/types.py index 6b92a65a7..f5688da0f 100644 --- a/kittens/ssh/options/types.py +++ b/kittens/ssh/options/types.py @@ -4,12 +4,13 @@ import typing option_names = ( # {{{ - 'env', 'hostname', 'remote_dir') # }}} + 'env', 'hostname', 'remote_dir', 'shell_integration') # }}} class Options: hostname: str = '*' remote_dir: str = '.local/share/kitty-ssh-kitten' + shell_integration: str = 'inherit' env: typing.Dict[str, str] = {} config_paths: typing.Tuple[str, ...] = () config_overrides: typing.Tuple[str, ...] = ()