Skip to content

Instantly share code, notes, and snippets.

@joltcan
Created October 5, 2017 08:03
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 joltcan/25a4fe53e28833d6eb34bad528ca3af8 to your computer and use it in GitHub Desktop.
Save joltcan/25a4fe53e28833d6eb34bad528ca3af8 to your computer and use it in GitHub Desktop.
SSH completion for known_hosts and config
function _own_ssh_known_hosts() {
perl -ne 'print "$1 " if /^([\w\d-\.]+).*$/i' ~/.ssh/known_hosts
}
function _own_ssh_hosts() {
perl -ne 'print "$1 " if /^host (.+)$/i' ~/.ssh/config
}
complete -W "$(_own_ssh_hosts)" ssh
complete -W "$(_own_ssh_known_hosts)" ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment