SSH completion

I hate it when I need to type the entire host I want to connect to. So I’ve added this to my ~/.bash_profile which autocompletes the ssh command based on my ~/.ssh/config

complete -W “$(awk ‘/^\s*Host\s*/ { sub(/^\s*Host /, “”); print; }’ ~/.ssh/config)” ssh

Thanks to @janmoesen for fixing the error.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation