File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ _curl()
7676 return
7777 ;;
7878 --pubkey)
79- _filedir pub
79+ _xfunc ssh _ssh_identityfile pub
8080 return
8181 ;;
8282 --stderr)
Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ _ssh_suboption()
108108 canonicalizehostname)
109109 COMPREPLY=( $( compgen -W ' yes no always' -- " $cur " ) )
110110 ;;
111+ identityfile)
112+ _ssh_identityfile
113+ ;;
111114 * file|identityagent|include|controlpath|revokedhostkeys|xauthlocation)
112115 _filedir
113116 ;;
@@ -220,6 +223,17 @@ _ssh_configfile()
220223 done
221224}
222225
226+ # With $1 set, look for public key files, else private
227+ _ssh_identityfile ()
228+ {
229+ [[ -z $cur && -d ~ /.ssh ]] && cur=~ /.ssh/id
230+ _filedir
231+ if (( ${# COMPREPLY[@]} > 0 )) ; then
232+ COMPREPLY=( $( compgen -W ' ${COMPREPLY[@]}' \
233+ -X " ${1: +! } *.pub" -- " $cur " ) )
234+ fi
235+ }
236+
223237_ssh ()
224238{
225239 local cur prev words cword
@@ -252,10 +266,14 @@ _ssh()
252266 -* [DeLpRW])
253267 return
254268 ;;
255- -* [EFiS ])
269+ -* [EFS ])
256270 _filedir
257271 return
258272 ;;
273+ -* i)
274+ _ssh_identityfile
275+ return
276+ ;;
259277 -* I)
260278 _filedir so
261279 return
@@ -335,10 +353,14 @@ _sftp()
335353 -* [BDlPRs])
336354 return
337355 ;;
338- -* [bFi ])
356+ -* [bF ])
339357 _filedir
340358 return
341359 ;;
360+ -* i)
361+ _ssh_identityfile
362+ return
363+ ;;
342364 -* c)
343365 _ssh_ciphers
344366 return
@@ -464,11 +486,16 @@ _scp()
464486 COMPREPLY=( " ${COMPREPLY[@]/%/ } " )
465487 return
466488 ;;
467- -* [Fi] )
489+ -* F )
468490 _filedir
469491 compopt +o nospace
470492 return
471493 ;;
494+ -* i)
495+ _ssh_identityfile
496+ compopt +o nospace
497+ return
498+ ;;
472499 -* J)
473500 _known_hosts_real -a -F " $configfile " -- " $cur "
474501 return
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ _ssh_copy_id()
99
1010 case $prev in
1111 -i)
12- _filedir pub
12+ _xfunc ssh _ssh_identityfile pub
1313 return
1414 ;;
1515 -p)
You can’t perform that action at this time.
0 commit comments