Last active
July 6, 2017 04:02
-
-
Save vortexau/7d9f7a32ee3643269db7dab9629bd87f to your computer and use it in GitHub Desktop.
This file contains 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
# Custom hosts completion from included SSH configs: | |
zstyle -e ':completion:*:hosts' hosts 'reply=( | |
${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } | |
${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} | |
${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} | |
${=${${${${(@M)${(f)"$(cat ~/.ssh/config.d/* 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} | |
)' | |
# The last line above supports reading from files inside a local SSH configuration directory. It pulls | |
# all configured hosts and allows them to be used for tab completion. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment