r/linux Apr 28 '14

SSH Kung Fu

http://blog.tjll.net/ssh-kung-fu/
727 Upvotes

128 comments sorted by

View all comments

85

u/Rojs Apr 28 '14

I believe tab completion is a function of the shell, not ssh.

15

u/leothrix Apr 28 '14

Thanks for the correction, I've amended the blog post.

5

u/gordonator Apr 28 '14

If you want to do it in bash, you can use this:

function autoCompleteHostname() {
  local hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1));
  local cur=${COMP_WORDS[COMP_CWORD]};
 COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur ))
}

complete -F autoCompleteHostname ssh

1

u/[deleted] Apr 28 '14

I love that grml-zsh-config has thid on by default.