From 42b3b725deef4ee1cdc5e886538ad565cf086e95 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 12 Aug 2010 22:54:00 +0200 Subject: zshrc: add better ssh/scp completion Signed-off-by: Florian Pritz --- .zshrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.zshrc b/.zshrc index 3a41969..b80c14a 100644 --- a/.zshrc +++ b/.zshrc @@ -688,6 +688,20 @@ zstyle ':completion:*:rm:*' file-patterns '*:all-files' zstyle ':completion:*:wine:*' file-patterns '*.(exe|EXE):exe' +# don't complete usernames (the come from localhost!) +zstyle ':completion:*:(ssh|scp):*' users + +# complete ssh hostnames +[[ -r ~/.ssh/known_hosts ]] && _ssh_hosts=(${${${${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}%%:*}#\[}%\]}) || _ssh_hosts=() +[[ -r ~/.ssh/config ]] && _ssh_config_hosts=($(sed -rn 's/host\s+(.+)/\1/ip' "$HOME/.ssh/config" | grep -v "\*" )) || _ssh_config_hosts=() +hosts=( + $(hostname) + "$_ssh_hosts[@]" + $_ssh_config_hosts[@] + localhost + ) +zstyle ':completion:*:hosts' hosts $hosts + # automagic url quoter autoload -U url-quote-magic zle -N self-insert url-quote-magic -- cgit v1.2.3-24-g4f1b