Last Updated: February 25, 2016
·
4.504K
· filipekiss

Auto Complete SSH Hosts

I had this for so long on my .zshrc file that I don't know what I'd do without it... A friend of mine once told me about this and I thought I could share with you guys. And don't worry. It's not zsh only. Works with almost any shell

Just paste the code below on your rc file (.zshrc, .bashrc... They're usually on your $HOME)

complete -o default -o nospace -W “$(awk ‘/^Host / {print $2}’ < $HOME/.ssh/config) scp sftp SSH

You'll need to use a config file to list your hosts (you can read more about it here), but that's pretty much it :)

1 Response
Add your response

This doesn't seem to work .. also, you've got smart quotes in there, so that might be part of the problem.

over 1 year ago ·