I found the following script (for bash) that enables me to get tab completion for any hostname I've connected to (from
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
However, the problem is that the tab completion doesn't work after I've typed a username.
How can I improve this so if I type...
and expect it to complete "myhostname.com" it will be able to do so?
It would be even better if it could tab whole strings (user@hostname) as well, but I can live with either option. Without the first, this isn't much use unless my host username matches the local username.