Tab complete for SSH

This snippet from .bashrc/.bash_profile was gifted from Marcel Molina, but I thought I would share because it’s life changing. Put this in your .bashrc or .bash_profile:

SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | \
cut -f 1 -d ‘ ’ | \
sed -e s/,.*//g | \
uniq | \
egrep -v [0123456789]) )
 complete -o default -W ”${SSH_COMPLETE[*]}” ssh
Advertisements

2 thoughts on “Tab complete for SSH

  1. This was indeed useful for me.
    Thank you!
    One little hint though. One can not see the black text of the code part on the Hemingway theme. I had to select the text to see it…
    Greetings!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s