I love bash

Tab-complete ssh hostnames

How much time do you think you’d save if you could tab-complete the hostname every time you fired up ssh?

Put this in your .bash_profile:

SSH_COMPLETE=( $(cut -f1 -d' ' ~/.ssh/known_hosts |\
tr ',' '\n' |\
sort -u |\
grep -e '[:alpha:]') )
complete -o default -W "${SSH_COMPLETE[*]}" ssh

Enjoy 🙂

Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.