completion/ssh-copy-id: add completion (#9675)

Add completions for ssh-copy-id.

Refactored __ssh_history_completions into its own file for autoloading across completions.
This commit is contained in:
NextAlone 2023-03-23 01:24:18 +08:00 committed by GitHub
parent ff34c1a573
commit 45b6622986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 112 additions and 5 deletions

View File

@ -51,6 +51,7 @@ Completions
- ``apkanalyzer`` - ``apkanalyzer``
- ``scrypt`` - ``scrypt``
- ``fastboot`` - ``fastboot``
- ``ssh-copy-id``
- git's completion for ``git-foo``-style commands was fixed (:issue:`9457`) - git's completion for ``git-foo``-style commands was fixed (:issue:`9457`)
- File completion now offers ``../`` and ``./`` again (:issue:`9477`) - File completion now offers ``../`` and ``./`` again (:issue:`9477`)

View File

@ -0,0 +1,108 @@
# Commands
complete -c ssh-copy-id -d Remote -xa "(__fish_complete_user_at_hosts)"
complete -c ssh-copy-id -d Remote -k -fa '(__ssh_history_completions)'
# Options
complete -c ssh-copy-id -s i -d IdentityFile -r -F
complete -c ssh-copy-id -s p -d Port -r -x
complete -c ssh-copy-id -s F -d 'Alternate ssh config file' -r -F
# Load completions shared by various ssh tools like ssh, scp and sftp.
complete -c ssh-copy-id -s o -d Options -xa "
AddKeysToAgent
AddressFamily
BatchMode
BindAddress
BindInterface
CanonicalDomains
CanonicalizeFallbackLocal
CanonicalizeHostname
CanonicalizeMaxDots
CanonicalizePermittedCNAMEs
CASignatureAlgorithms
CertificateFile
ChallengeResponseAuthentication
CheckHostIP
Ciphers
ClearAllForwardings
Compression
ConnectionAttempts
ConnectTimeout
ControlMaster
ControlPath
ControlPersist
DynamicForward
EscapeChar
ExitOnForwardFailure
FingerprintHash
ForwardAgent
ForwardX11
ForwardX11Timeout
ForwardX11Trusted
GatewayPorts
GlobalKnownHostsFile
GSSAPIAuthentication
GSSAPIClientIdentity
GSSAPIDelegateCredentials
GSSAPIKexAlgorithms
GSSAPIKeyExchange
GSSAPIRenewalForcesRekey
GSSAPIServerIdentity
GSSAPITrustDns
HashKnownHosts
Host
HostbasedAuthentication
HostbasedKeyTypes
HostKeyAlgorithms
HostKeyAlias
Hostname
IdentitiesOnly
IdentityAgent
IdentityFile
IPQoS
KbdInteractiveAuthentication
KbdInteractiveDevices
KexAlgorithms
LocalCommand
LocalForward
LogLevel
MACs
Match
NoHostAuthenticationForLocalhost
NumberOfPasswordPrompts
PasswordAuthentication
PermitLocalCommand
PKCS11Provider
Port
PreferredAuthentications
ProxyCommand
ProxyJump
ProxyUseFdpass
PubkeyAcceptedKeyTypes
PubkeyAuthentication
RekeyLimit
RemoteCommand
RemoteForward
RequestTTY
SendEnv
ServerAliveCountMax
ServerAliveInterval
SetEnv
StreamLocalBindMask
StreamLocalBindUnlink
StrictHostKeyChecking
TCPKeepAlive
Tunnel
TunnelDevice
UpdateHostKeys
User
UserKnownHostsFile
VerifyHostKeyDNS
VisualHostKey
XAuthLocation
"
complete -c ssh-copy-id -s f -d 'Force mode'
complete -c ssh-copy-id -s n -d 'Dry run'
complete -c ssh-copy-id -s s -d 'Use sftp'
complete -c ssh-copy-id -s h -s \? -d 'Show help'

View File

@ -5,11 +5,6 @@ __fish_complete_ssh ssh
# ssh specific completions # ssh specific completions
# #
# Also retrieve `user@host` entries from history
function __ssh_history_completions
history --prefix ssh --max=100 | string replace -rf '.* ([A-Za-z0-9._:-]+@[A-Za-z0-9._:-]+).*' '$1'
end
complete -c ssh -d Remote -xa "(__fish_complete_user_at_hosts)" complete -c ssh -d Remote -xa "(__fish_complete_user_at_hosts)"
complete -c ssh -d Remote -k -fa '(__ssh_history_completions)' complete -c ssh -d Remote -k -fa '(__ssh_history_completions)'

View File

@ -0,0 +1,3 @@
function __ssh_history_completions -d "Retrieve `user@host` entries from history"
history --prefix ssh --max=100 | string replace -rf '.* ([A-Za-z0-9._:-]+@[A-Za-z0-9._:-]+).*' '$1'
end