Parcourir la source

[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.
Matt Hamilton il y a 5 ans
Parent
commit
2436a6da28
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      modules/completion/init.zsh

+ 5 - 0
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=()'