From e2117ee8a4b62cf4e0519ed6da41edd5ab3bd817 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Jul 2022 08:29:49 +0530 Subject: [PATCH] ssh kitten: Allow completion of ssh options between the destination and command This contravenes the documented command line parsing behavior of ssh but matches its actual implementation. Sigh. Fixes #5322 --- docs/changelog.rst | 2 ++ kittens/ssh/completion.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6b7a4f67b..0c9c26b2d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -87,6 +87,8 @@ Detailed list of changes - Allow showing the working directory of the active window in tab titles (:pull:`5314`) +- ssh kitten: Allow completion of ssh options between the destination and command (:iss:`5322`) + 0.25.2 [2022-06-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kittens/ssh/completion.py b/kittens/ssh/completion.py index 6fe21f773..8a2710451 100644 --- a/kittens/ssh/completion.py +++ b/kittens/ssh/completion.py @@ -291,6 +291,7 @@ def complete_option(ans: Completions, prefix: str = '-') -> None: def complete(ans: Completions, words: Sequence[str], new_word: bool) -> None: options = ssh_options() expecting_arg = False + seen_destination = False types = ['' for i in range(len(words))] for i, word in enumerate(words): if expecting_arg: @@ -302,8 +303,10 @@ def complete(ans: Completions, words: Sequence[str], new_word: bool) -> None: if len(word) == 2 and options.get(word[1]): expecting_arg = True continue + if seen_destination: + break types[i] = 'destination' - break + seen_destination = True if new_word: if words: if expecting_arg: