Skip to content

Instantly share code, notes, and snippets.

@roder
Created October 5, 2009 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roder/202244 to your computer and use it in GitHub Desktop.
Save roder/202244 to your computer and use it in GitHub Desktop.
# copy this to ~/.bashrc
_complete_ssh_hosts () {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`
grep "^host " ~/.ssh/config | \
awk '{print $2}'
`
COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
return 0
}
complete -F _complete_ssh_hosts ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment