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.

(cherry picked from commit 45b6622986)

Conflicts:
	CHANGELOG.rst
This commit is contained in:
NextAlone 2023-03-23 01:24:18 +08:00 committed by Mahmoud Al-Qudsi
parent 7f867298e7
commit 37e7e90bff
4 changed files with 112 additions and 5 deletions

View File

@ -56,6 +56,7 @@ Completions
- ``scrypt`` (:issue:`9583`)
- ``stow`` (:issue:`9571`)
- ``trash`` and helper utilities ``trash-empty``, ``trash-list``, ``trash-put``, ``trash-restore`` (:issue:`9560`)
- ``ssh-copy-id`` (:issue:`9675`)
- Improvements to many completions, including the speed of completing directories in WSL 2 (:issue:`9574`).
- Completions using ``__fish_complete_suffix`` are now offered in the correct order, fixing a regression in 3.6.0 (:issue:`8924`).
- ``git`` completions for ``git-foo``-style commands was restored, fixing a regression in 3.6.0 (:issue:`9457`).

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
#
# 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 -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