Issue
I have read this tutorial on bash auto-completion An introduction to bash completion and I am trying to get the same auto-completion that is already done for ssh
for one of my functions (that is loaded from .profile
); which acts pretty much as an alias.
What I am trying to do is : get the same auto-completion, that is provided by default for ssh
(which is the function _known_hosts
; do complete -p | grep ssh
and you will get complete -F _known_hosts /etc/init.d/ssh
), and get it for my own function (which is installed like you woul install an alias, and that in fact does a scp
and then an ssh
with the original argument)
Solution
The completion function for ssh
here is _ssh
.
You can see this with complete -p ssh
(it should also have been in your grep
output) though it appears to be auto-loaded and so will not show up until after you have used it once in that session.
Anyway, that being said you should just be able to hook _ssh
up to your function as well I would think.
complete -F _ssh myfunc
Answered By - Etan Reisner Answer Checked By - Gilberto Lyons (WPSolving Admin)