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