summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.zshrc14
1 files changed, 14 insertions, 0 deletions
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