diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index e6359786e..cf6b1ca26 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -358,6 +358,15 @@ def get_connection_data(args: List[str], cwd: str = '', extra_args: Tuple[str, . host_name = arg if not host_name: return None + if host_name.startswith('ssh://'): + from urllib.parse import urlparse + purl = urlparse(host_name) + if purl.hostname: + host_name = purl.hostname + if purl.username: + host_name = f'{purl.username}@{host_name}' + if port is None and purl.port: + port = purl.port if identity_file: if not os.path.isabs(identity_file): identity_file = os.path.expanduser(identity_file) diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py index 426e703c2..919a9d362 100644 --- a/kitty_tests/ssh.py +++ b/kitty_tests/ssh.py @@ -55,6 +55,7 @@ print(' '.join(map(str, buf)))'''), lines=13, cols=77) t('ssh un@ip -i ident -p34', host='un@ip', port=34, identity_file='ident') t('ssh un@ip -iident -p34', host='un@ip', port=34, identity_file='ident') t('ssh -p 33 main', port=33) + t('ssh -p 34 ssh://un@ip:33/', host='un@ip', port=34) t('ssh --kitten=one -p 12 --kitten two -ix main', identity_file='x', port=12, extra_args=(('--kitten', 'one'), ('--kitten', 'two'))) self.assertTrue(runtime_dir())