Skip to content

Instantly share code, notes, and snippets.

@mkrakauer-rio
Created April 17, 2018 20:50
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 mkrakauer-rio/4bd258bf38988509805aca3b13f9ca6d to your computer and use it in GitHub Desktop.
Save mkrakauer-rio/4bd258bf38988509805aca3b13f9ca6d to your computer and use it in GitHub Desktop.
Mac SSH Autocomplete
_complete_ssh_hosts() {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/config | \
grep "^Host " | \
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