From 2436a6da28d466b513fd0adbd4f6e8e8a4cd0a4b Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Mon, 17 Sep 2018 01:28:26 -0400 Subject: [PATCH] [completion] Fix ssh completion for ~/.ssh/config I think this change results in the _expected_ behavior. Users can always override this by overriding the zstyle, as that is a benefit of using zstyles. Ref: https://www.zsh.org/mla/users/2015/msg00467.html and `which _ssh_hosts` Fixes #46. Closes #294. --- modules/completion/init.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 12b2023..80bef9b 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -92,3 +92,8 @@ zstyle ':completion:*:history-words' menu yes # ignore multiple entries. zstyle ':completion:*:(rm|kill|diff):*' ignore-line other zstyle ':completion:*:rm:*' file-patterns '*:all-files' + +# If the _my_hosts function is defined, it will be called to add the ssh hosts +# completion, otherwise _ssh_hosts will fall through and read the ~/.ssh/config +zstyle -e ':completion:*:*:ssh:*:my-accounts' users-hosts \ + '[[ -f ${HOME}/.ssh/config && ${key} == hosts ]] && key=my_hosts reply=()'