summaryrefslogtreecommitdiffstats
path: root/completions/ssh-keygen
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:18 +0000
commitf4acb49ea148cdd899f7f29f1591c7bc853c2135 (patch)
treeb62d60873864065d6428a84a119dd8a3c90f1397 /completions/ssh-keygen
parentAdding upstream version 1:2.11. (diff)
downloadbash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.tar.xz
bash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.zip
Adding upstream version 1:2.12.0.upstream/1%2.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/ssh-keygen')
-rw-r--r--completions/ssh-keygen80
1 files changed, 44 insertions, 36 deletions
diff --git a/completions/ssh-keygen b/completions/ssh-keygen
index 0e629a5..3f9d175 100644
--- a/completions/ssh-keygen
+++ b/completions/ssh-keygen
@@ -1,16 +1,16 @@
# ssh-keygen(1) completion -*- shell-script -*-
-_ssh_keygen()
+_comp_cmd_ssh_keygen()
{
- local cur prev words cword
- _init_completion -n := || return
+ local cur prev words cword comp_args
+ _comp_initialize -n := -- "$@" || return
case $prev in
-*[aCIJjMNPSVWz])
return
;;
-*b)
- local -a sizes
+ local -a sizes=()
case "${words[*]}" in
*" -t dsa"?( *))
sizes=(1024)
@@ -22,102 +22,110 @@ _ssh_keygen()
sizes=(1024 2048 3072 4096)
;;
esac
- COMPREPLY=($(compgen -W '${sizes[@]}' -- "$cur"))
+ ((${#sizes[@]})) &&
+ _comp_compgen -- -W '"${sizes[@]}"'
return
;;
-*E)
- COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
+ _comp_compgen -- -W 'md5 sha256'
return
;;
-*[FR])
# TODO: trim this down to actual entries in known hosts files
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*[Dw])
- _filedir so
+ _comp_compgen_filedir so
return
;;
-*[fGKsT])
- _filedir
+ _comp_compgen_filedir
return
;;
-*m)
- COMPREPLY=($(compgen -W 'PEM PKCS8 RFC4716' -- "$cur"))
+ _comp_compgen -- -W 'PEM PKCS8 RFC4716'
return
;;
-*n)
[[ ${words[*]} != *\ -*Y\ * ]] || return
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
if [[ ${words[*]} == *\ -*h\ * ]]; then
- _known_hosts_real -- "${cur##*,}"
+ _comp_compgen_known_hosts -- "${cur##*,}"
+ ((${#COMPREPLY[@]})) &&
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
else
- COMPREPLY=($(compgen -u -- "${cur##*,}"))
+ _comp_delimited , -u
fi
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
-*O)
if [[ $cur != *=* ]]; then
- COMPREPLY=($(compgen -W '
- clear critical: extension: force-command=
+ _comp_compgen -- -W 'clear critical: extension: force-command=
no-agent-forwarding no-port-forwarding no-pty no-user-rc
no-x11-forwarding permit-agent-forwarding
permit-port-forwarding permit-pty permit-user-rc
permit-X11-forwarding no-touch-required source-address=
+ verify-required
lines= start-line= checkpoint= memory= start= generator=
- application challenge= device resident user
- write-attestation-path
- ' -- "$cur"))
+ application= challenge= device= no-touch-required resident
+ user= write-attestation='
+
[[ ${COMPREPLY-} == *[:=] ]] && compopt -o nospace
- __ltrim_colon_completions "$cur"
+ _comp_ltrim_colon_completions "$cur"
else
case $cur in
force-command=*)
compopt -o filenames
- COMPREPLY=($(compgen -c -- "${cur#*=}"))
+ _comp_compgen -c "${cur#*=}" commands
+ ;;
+ checkpoint=* | challenge=* | write-attestation=*)
+ _comp_compgen -c "${cur#*=}" filedir
+ ;;
+ application=*([^:=]))
+ _comp_compgen -c "${cur#*=}" -- -W "ssh:"
+ compopt -o nospace
;;
- checkpoint=* | challenge=*)
- cur=${cur#*=}
- _filedir
+ user=*)
+ _comp_compgen -c "${cur#*=}" -- -u
;;
esac
fi
return
;;
-*r)
- [[ ${words[*]} != *\ -*Y\ * ]] || _filedir
+ [[ ${words[*]} != *\ -*Y\ * ]] || _comp_compgen_filedir
return
;;
-*t)
- local protocols=$(_xfunc ssh _ssh_query "$1" protocol-version)
+ # Prefer `ssh` from same dir for resolving options, etc
+ local pathcmd protocols
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -v protocols -x ssh query protocol-version
local types='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa'
- if [[ $protocols == *1* ]]; then
+ if [[ ${protocols[*]} == *1* ]]; then
types+=' rsa1'
fi
- COMPREPLY=($(compgen -W "$types" -- "$cur"))
+ _comp_compgen -- -W "$types"
return
;;
-*Y)
- COMPREPLY=($(compgen -W 'find-principals check-novalidate sign
- verify' -- "$cur"))
+ _comp_compgen -- -W 'find-principals check-novalidate sign verify'
return
;;
esac
+ _comp_compgen_set
if [[ $cur == -* ]]; then
- local opts=$(_parse_usage "$1" "-?")
- [[ -z $opts ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ _comp_compgen_usage -- "-?" ||
+ _comp_compgen_help -- "-?" # OpenSSH < 7
fi
if [[ ${words[*]} == *\ -*s\ * ]]; then
- _filedir pub
+ _comp_compgen -a filedir pub
fi
} &&
- complete -F _ssh_keygen ssh-keygen
+ complete -F _comp_cmd_ssh_keygen ssh-keygen
# ex: filetype=sh