Skip to content

Instantly share code, notes, and snippets.

@frdmn
Created March 29, 2016 10:39
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 frdmn/41bc8cf01f58ddbc369b to your computer and use it in GitHub Desktop.
Save frdmn/41bc8cf01f58ddbc369b to your computer and use it in GitHub Desktop.
ssh-hosts.zsh plugin
h=()
if [[ -r ~/.ssh/config ]]; then
h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
fi
if [[ -r ~/.ssh/known_hosts ]]; then
h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
fi
if [[ $#h -gt 0 ]]; then
zstyle ':completion:*:ssh:*' hosts $h
zstyle ':completion:*:slogin:*' hosts $h
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment