Skip to content

Instantly share code, notes, and snippets.

@nuBacuk
Created April 7, 2021 22:11
Show Gist options
  • Select an option

  • Save nuBacuk/e27fad7b2a659be52e06282c5c8b2f6d to your computer and use it in GitHub Desktop.

Select an option

Save nuBacuk/e27fad7b2a659be52e06282c5c8b2f6d to your computer and use it in GitHub Desktop.
zsh autocompletion
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