From cad5e1169c5bf89949235e1dfa66276946a62214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C5=82azie=C5=84ski?= Date: Fri, 8 Jan 2016 10:40:34 +0100 Subject: [PATCH] support for missing .ssh/config file for ssh completion --- .zshrc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index 9e61dae..13b6da7 100644 --- a/.zshrc +++ b/.zshrc @@ -92,8 +92,11 @@ zstyle ':completion:*' squeeze-slashes true zstyle ':completion::*:kill:*:*' command 'ps xf -U $USER -o pid,%cpu,cmd' zstyle ':completion::*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32' -zstyle ':completion:*:ssh:*' hosts ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*} -zstyle ':completion:*:scp:*' hosts ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*} + +list-ssh-hosts() { [[ -f $HOME/.ssh/config ]] && print -n $(cat $HOME/.ssh/config | sed '/^Host /!d;s/Host *\([^ \#]\+\)/\1/') } + +zstyle ':completion:*:ssh:*' hosts $(list-ssh-hosts) +zstyle ':completion:*:scp:*' hosts $(list-ssh-hosts) zstyle ':completion:*:ssh:*' users # disables users completion zstyle ':completion:*:scp:*' users # disables users completion