Created
June 14, 2018 15:06
-
-
Save jsonUK/0ea33f8f42fa2578823e96a071d72ec7 to your computer and use it in GitHub Desktop.
Tab auto-complete your ssh configs in your terminal on scp ssh etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tab autocomplete ssh hosts | |
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