From e5ba15949b12e33ceddd7c08b5f772d07e16b483 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 27 Feb 2022 21:02:49 +0530 Subject: [PATCH] $size doesnt need to be global --- docs/faq.rst | 18 ++++-------------- kittens/ssh/main.py | 12 +++--------- shell-integration/ssh/bootstrap.sh | 3 +-- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index a45c118f2..f15a6e517 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -47,22 +47,12 @@ terminfo files to the server:: kitty +kitten ssh myserver This ssh kitten takes all the same command line arguments -as ssh, you can alias it to ssh in your shell's rc files to avoid having to -type it each time:: +as ssh, you can alias it to something small in your shell's rc files to avoid +having to type it each time:: - alias ssh="kitty +kitten ssh" + alias s="kitty +kitten ssh" -Remember to also setup :ref:`shell_integration` for completion and other -niceties. - -If for some reason that does not work (typically because the server is using a -non POSIX compliant shell as ``/bin/sh``), you can try using it with ``python`` -instead:: - - kitty +kitten ssh use-python myserver - -If that also fails, perhaps because python is not installed on the remote -server, use the following one-liner instead (it +If the ssh kitten fails, use the following one-liner instead (it is slower as it needs to ssh into the server twice, but will work with most servers):: diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index 0e46062a6..518bc6db9 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -67,7 +67,7 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str]) -> bytes: return ans def filter_files(tarinfo: tarfile.TarInfo) -> Optional[tarfile.TarInfo]: - if tarinfo.name.endswith('ssh/bootstrap.sh') or tarinfo.name.endswith('ssh/bootstrap.py'): + if tarinfo.name.endswith('ssh/bootstrap.sh'): return None return normalize_tarinfo(tarinfo) @@ -324,16 +324,10 @@ def get_posix_cmd(remote_args: List[str]) -> List[str]: return [f'sh -c {shlex.quote(sh_script)}'] -def get_python_cmd(remote_args: List[str]) -> List[str]: - raise NotImplementedError('TODO: Implement me') - - def main(args: List[str]) -> NoReturn: args = args[1:] - use_posix = True if args and args[0] == 'use-python': - args = args[1:] - use_posix = False + args = args[1:] # backwards compat from when we had a python implementation try: ssh_args, server_args, passthrough = parse_ssh_args(args) except InvalidSSHArgs as e: @@ -347,7 +341,7 @@ def main(args: List[str]) -> NoReturn: cmd.append('-t') cmd.append('--') cmd.append(hostname) - f = get_posix_cmd if use_posix else get_python_cmd + f = get_posix_cmd cmd += f(remote_args) os.execvp('ssh', cmd) diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index 088f94b1f..ddefd4899 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -35,7 +35,6 @@ data_complete="n" leading_data="" dsc_to_kitty "ssh" "hostname=$hostname:pwfile=$password_filename:pw=$data_password" -size="" record_separator=$(printf "\036") untar_and_read_env() { @@ -47,7 +46,7 @@ untar_and_read_env() { # using dd with bs=1 is very slow, so use head. On non GNU coreutils head # does not limit itself to reading -c bytes only from the pipe so we can potentially lose # some trailing data, for instance if the user starts typing. Cant be helped. - command head -c "$size" < /dev/tty | command base64 -d | command tar xjf - --no-same-owner -C "$tdir"; + command head -c "$1" < /dev/tty | command base64 -d | command tar xjf - --no-same-owner -C "$tdir"; data_file="$tdir/kitty-ssh-kitten-data.sh"; [ -f "$data_file" ] && . "$data_file"; data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR"