This question was originally asked on SO, which is incorrect. As I was not able to (get it) moved to serverfault, I am re-asking it.
I am trying to configure tab completion for the ssh
command in zsh
to use an additional known_hosts
file (which not located in ~/.ssh
). By additional I mean I still want to use the "default" known_hosts
file.
Currently, when I hit TAB
after ssh
, I get a list of hosts which seems to come from ~/.ssh/known_hosts
and (probably) /etc/hosts
. I would like to also get the hosts listed in ~/other/path/known_hosts
.
I found a lot of material online, but somehow I cannot wrap my head around this one. The zsh webiste for example lists a style
called known-hosts-files
which sounds very promising. Also when I see how it is used it seems quite to the point.
But I cannot figure out how to use known-hosts-files
.
I tried, for example, the following in my .zshrc
:
zstyle ':completion:*:*:ssh:*:*' known-hosts-files '~/other/path/known_hosts'
and many variations of it to no avail.
For good measure I have also added (in my .zshrc
):
zstyle ":completion:*:commands" rehash 1
but this did not change anything.
There is an older answer here on serverfault and another answer) tackling the same question, but I do not fully understand them and it seems that known-hosts-files
should do exactly what I want?
I also use Oh-my-zsh, if that matters...