zshell: rsync hostname completion with zsh

If you use ssh a lot with zsh and have a lot of entries in your hostsfile (/etc/hosts) you might find it convenient to disable completion from these hosts by using:

zstyle ':completion:*' hosts off

However, this may give you adverse affects, and your hostnames may stop auto-completing with rsync – in order to fix this try also adding this in to your .zshrc

zstyle -s ':completion:*:hosts' hosts _ssh_config
[[ -r ~/.ssh/config ]] && _ssh_config+=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p'))
zstyle ':completion:*:hosts' hosts $_ssh_config

If you also use oh-my-zsh and are still having trouble, trying adding those lines after this line:

source $ZSH/oh-my-zsh.sh

Related Posts:

  • No Related Posts
This entry was posted in Tech Tips and tagged , . Bookmark the permalink.

One Response to zshell: rsync hostname completion with zsh

Leave a Reply

Your email address will not be published. Required fields are marked *