Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: hostname completion for ssh / scp



On Nov 3,  8:11pm, Fourhundred Thecat wrote:
} Subject: hostname completion for ssh / scp
}
}   ssh <TAB>
} 
} it offers me only the hostnames listed in ~/.ssh/config and completely
} ignores global ones defined in /etc/hosts
} 
} Tested on zsh 4.3.17

What does
    getent hosts
return on your system?  That's where _hosts gets the list of hosts.

Only if getent isn't present does it look directly at /etc/hosts,
and also at "ypcat hosts" if there is ypcat.

If getent isn't returning anything useful, you can replace it:

zstyle ':completion:*:hosts' command 'cat /etc/hosts'

Or explicitly list all the hosts yourself:

zstyle ':completion:*:hosts' hosts $(awk '/^[^#]/ {print $2}' /etc/hosts)

Note there have been several other fixes/improvements to ssh host-gathering
since zsh 5.0.



Messages sorted by: Reverse Date, Date, Thread, Author