Skip to content

Instantly share code, notes, and snippets.

@mrmanc
Last active January 2, 2016 13:59
Show Gist options
  • Save mrmanc/8313720 to your computer and use it in GitHub Desktop.
Save mrmanc/8313720 to your computer and use it in GitHub Desktop.
This will allow you to tab complete any hostname you've previously ssh'd to.
Taken from http://hints.macworld.com/article.php?story=20080317085050719
Put the below line in your .profile, .bash_profile or .bashrc file (whichever you use).
If you don't know which file to put it in, read this explanation:
http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment#answer-415444
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment