Skip to content

Commit

Permalink
ssh-keygen: add -b arg completions according to specified -t
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 29, 2020
1 parent edc4f9b commit 69b477b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion completions/ssh-keygen
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@ _ssh_keygen()
_init_completion -n = || return

case $prev in
-*[abCIJjMNPSVWz])
-*[aCIJjMNPSVWz])
return
;;
-*b)
local -a sizes
case "${words[*]}" in
*" -t dsa"?( *))
sizes=(1024)
;;
*" -t ecdsa"?( *))
sizes=(256 384 521)
;;
*" -t rsa"?( *))
sizes=(1024 2048 3072 4096)
;;
esac
COMPREPLY=( $(compgen -W '${sizes[@]}' -- "$cur") )
return
;;
-*E)
Expand Down
8 changes: 8 additions & 0 deletions test/t/test_ssh_keygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ def test_r_without_Y(self, completion):
@pytest.mark.complete("ssh-keygen -Y foo -r ")
def test_r_with_Y(self, completion):
assert "ssh/" in completion

@pytest.mark.complete("ssh-keygen -t ecdsa -b ")
def test_ecdsa_b(self, completion):
assert completion

@pytest.mark.complete("ssh-keygen -t ecdsa-sk -b ")
def test_ecdsa_sk_b(self, completion):
assert not completion

0 comments on commit 69b477b

Please sign in to comment.