Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh: add option completion. #179

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion ssh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,31 @@ local function supportedMACs(token) -- luacheck: no unused args
return macs
end

-- return the list of supported options
local function supportedOptions(token) -- luacheck: no unused args
-- curl --silent https://raw.githubusercontent.com/openssh/openssh-portable/master/ssh_config.5 | awk '$1==".It" && $2=="Cm" && $3!="Host" && $3!="Match" {print " "$3}' | sort
local options = {"AddKeysToAgent", "AddressFamily", "BatchMode", "BindAddress", "BindInterface",
"CanonicalDomains", "CanonicalizeFallbackLocal", "CanonicalizeHostname", "CanonicalizeMaxDots",
"CanonicalizePermittedCNAMEs", "CASignatureAlgorithms", "CertificateFile", "CheckHostIP",
"Ciphers", "ClearAllForwardings", "Compression", "ConnectionAttempts", "ConnectTimeout",
"ControlMaster", "ControlPath", "ControlPersist", "DynamicForward", "EnableEscapeCommandline",
"EnableSSHKeysign", "EscapeChar", "ExitOnForwardFailure", "FingerprintHash", "ForkAfterAuthentication",
"ForwardAgent", "ForwardX11", "ForwardX11Timeout", "ForwardX11Trusted", "GatewayPorts",
"GlobalKnownHostsFile", "GSSAPIAuthentication", "GSSAPIDelegateCredentials", "HashKnownHosts",
"HostbasedAcceptedAlgorithms", "HostbasedAuthentication", "HostKeyAlgorithms", "HostKeyAlias",
"Hostname", "IdentitiesOnly", "IdentityAgent", "IdentityFile", "IgnoreUnknown", "Include",
"IPQoS", "KbdInteractiveAuthentication", "KbdInteractiveDevices", "KexAlgorithms", "KnownHostsCommand",
"LocalCommand", "LocalForward", "LogLevel", "LogVerbose", "MACs", "NoHostAuthenticationForLocalhost",
"NumberOfPasswordPrompts", "ObscureKeystrokeTiming", "PasswordAuthentication", "PermitLocalCommand",
"PermitRemoteOpen", "PKCS11Provider", "Port", "PreferredAuthentications", "ProxyCommand", "ProxyJump",
"ProxyUseFdpass", "PubkeyAcceptedAlgorithms", "PubkeyAuthentication", "RekeyLimit", "RemoteCommand",
"RemoteForward", "RequestTTY", "RequiredRSASize", "RevokedHostKeys", "SecurityKeyProvider", "SendEnv",
"ServerAliveCountMax", "ServerAliveInterval", "SessionType", "SetEnv", "StdinNull", "StreamLocalBindMask",
"StreamLocalBindUnlink", "StrictHostKeyChecking", "SyslogFacility", "Tag", "TCPKeepAlive", "Tunnel",
"TunnelDevice", "UpdateHostKeys", "User", "UserKnownHostsFile", "VerifyHostKeyDNS", "VisualHostKey", "XAuthLocation"}
return options
end

local ssh_parser = parser({hosts_with_port_flag},
"-4", "-6", "-A", "-a", "-C", "-f", "-G", "-g", "-K", "-k", "-M",
"-N", "-n", "-q", "-s", "-T", "-t", "-V", "-v", "-X", "-x", "-Y", "-y",
Expand All @@ -177,7 +202,7 @@ local ssh_parser = parser({hosts_with_port_flag},
"-l" .. parser({fromhistory=true}),
"-m" .. parser({supportedMACs}),
"-O" .. parser({fromhistory=true}),
"-o" .. parser({fromhistory=true}),
"-o" .. parser({supportedOptions}),
"-p" .. parser({fromhistory=true}),
"-Q" .. parser({"cipher", "cipher_auth", "help", "mac", "kex", "kex-gss", "key", "key-cert", "key-plain", "key-sig", "protocol-version", "sig"}), -- luacheck: no max line length
"-R" .. parser({fromhistory=true}),
Expand Down