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()
76
76
return
77
77
;;
78
78
--pubkey)
79
- _filedir pub
79
+ _xfunc ssh _ssh_identityfile pub
80
80
return
81
81
;;
82
82
--stderr)
Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ _ssh_suboption()
108
108
canonicalizehostname)
109
109
COMPREPLY=( $( compgen -W ' yes no always' -- " $cur " ) )
110
110
;;
111
+ identityfile)
112
+ _ssh_identityfile
113
+ ;;
111
114
* file|identityagent|include|controlpath|revokedhostkeys|xauthlocation)
112
115
_filedir
113
116
;;
@@ -220,6 +223,17 @@ _ssh_configfile()
220
223
done
221
224
}
222
225
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
+
223
237
_ssh ()
224
238
{
225
239
local cur prev words cword
@@ -252,10 +266,14 @@ _ssh()
252
266
-* [DeLpRW])
253
267
return
254
268
;;
255
- -* [EFiS ])
269
+ -* [EFS ])
256
270
_filedir
257
271
return
258
272
;;
273
+ -* i)
274
+ _ssh_identityfile
275
+ return
276
+ ;;
259
277
-* I)
260
278
_filedir so
261
279
return
@@ -335,10 +353,14 @@ _sftp()
335
353
-* [BDlPRs])
336
354
return
337
355
;;
338
- -* [bFi ])
356
+ -* [bF ])
339
357
_filedir
340
358
return
341
359
;;
360
+ -* i)
361
+ _ssh_identityfile
362
+ return
363
+ ;;
342
364
-* c)
343
365
_ssh_ciphers
344
366
return
@@ -464,11 +486,16 @@ _scp()
464
486
COMPREPLY=( " ${COMPREPLY[@]/%/ } " )
465
487
return
466
488
;;
467
- -* [Fi] )
489
+ -* F )
468
490
_filedir
469
491
compopt +o nospace
470
492
return
471
493
;;
494
+ -* i)
495
+ _ssh_identityfile
496
+ compopt +o nospace
497
+ return
498
+ ;;
472
499
-* J)
473
500
_known_hosts_real -a -F " $configfile " -- " $cur "
474
501
return
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ _ssh_copy_id()
9
9
10
10
case $prev in
11
11
-i)
12
- _filedir pub
12
+ _xfunc ssh _ssh_identityfile pub
13
13
return
14
14
;;
15
15
-p)
You can’t perform that action at this time.
0 commit comments