Reputation: 4169
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)
Upvotes: 11
Views: 4947
Reputation: 57
Check also this question : How to enable autocomplete subcommnads on function that's call kubectl
It allowed me to make aliases like alias ks='kubectl -n kube-system
, alias kc1='kubectl --context c1'
working with autocompletion.
It relies on complete-alias : https://github.com/cykerway/complete-alias
Upvotes: 0
Reputation: 81032
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
Upvotes: 8