Add an option to control the login shell

This commit is contained in:
Kovid Goyal
2022-03-05 11:16:15 +05:30
parent 0bd1676978
commit 01dd0416ac
6 changed files with 27 additions and 7 deletions

View File

@@ -96,6 +96,8 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str]) -> bytes:
env.update(ssh_opts.env)
env['KITTY_SHELL_INTEGRATION'] = ksi or DELETE_ENV_VAR
env['KITTY_SSH_KITTEN_DATA_DIR'] = ssh_opts.remote_dir
if ssh_opts.login_shell:
env['KITTY_LOGIN_SHELL'] = ssh_opts.login_shell
env_script = serialize_env(env, base_env)
buf = io.BytesIO()
with tarfile.open(mode='w:bz2', fileobj=buf, encoding='utf-8') as tf:
@@ -173,7 +175,7 @@ def prepare_script(ans: str, replacements: Dict[str, str]) -> str:
atexit.register(safe_remove, tf.name)
replacements['DATA_PASSWORD'] = pw
replacements['PASSWORD_FILENAME'] = os.path.basename(tf.name)
for k in ('EXEC_CMD', 'OVERRIDE_LOGIN_SHELL'):
for k in ('EXEC_CMD',):
replacements[k] = replacements.get(k, '')
def sub(m: 're.Match[str]') -> str:

View File

@@ -91,5 +91,8 @@ for details on how this setting works. The special value :code:`inherit` means
use the setting from kitty.conf. This setting is useful for overriding
integration on a per-host basis.''')
opt('login_shell', '', long_text='''
The login shell to execute on the remote host. By default, the remote user account's
login shell is used.''')
egr() # }}}

View File

@@ -21,6 +21,9 @@ class Parser:
def interpreter(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['interpreter'] = str(val)
def login_shell(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['login_shell'] = str(val)
def remote_dir(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['remote_dir'] = relative_dir(val)

View File

@@ -5,12 +5,19 @@ import kittens.ssh.copy
option_names = ( # {{{
'copy', 'env', 'hostname', 'interpreter', 'remote_dir', 'shell_integration') # }}}
'copy',
'env',
'hostname',
'interpreter',
'login_shell',
'remote_dir',
'shell_integration') # }}}
class Options:
hostname: str = '*'
interpreter: str = 'sh'
login_shell: str = ''
remote_dir: str = '.local/share/kitty-ssh-kitten'
shell_integration: str = 'inherit'
copy: typing.Dict[str, kittens.ssh.copy.CopyInstruction] = {}