Skip to content

Instantly share code, notes, and snippets.

@peelman
Created February 8, 2012 21:03
Bash AutoComplete from known_hosts
# add to ~/.bash_profile, and close/reopen a shell. Will autocomplete any hosts found in known_hosts.
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
@dtwilliamson
Copy link

complete -W "$(awk -F , '/\[/ {hosts[$1]} END {for (host in hosts) {print host}' "$HOME/.ssh/known hosts")"

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment