summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-08-12 22:54:00 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-08-12 22:54:00 +0200
commit42b3b725deef4ee1cdc5e886538ad565cf086e95 (patch)
tree25ebb02f04e371a70281ecc6f85b72c096c04f58
parent398e3cc2e7d73ad8f2619f4750973873a10bbc2b (diff)
downloaddotfiles-42b3b725deef4ee1cdc5e886538ad565cf086e95.tar.gz
dotfiles-42b3b725deef4ee1cdc5e886538ad565cf086e95.tar.xz
zshrc: add better ssh/scp completion
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-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