From e23e9229f2d4856f7091eca2c195dfa9fbda21d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C5=82azie=C5=84ski?= Date: Fri, 19 May 2017 23:08:37 +0200 Subject: [PATCH] Parse ssh config only once for completions --- .zshrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.zshrc b/.zshrc index 12a2021..4ecf8e3 100644 --- a/.zshrc +++ b/.zshrc @@ -125,10 +125,10 @@ zstyle ':completion::*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32' # sudo completion zstyle ':completion:*:sudo:*' command-path append /sbin /usr/sbin -list-ssh-hosts() { [[ -f $HOME/.ssh/config ]] && print -n $(cat $HOME/.ssh/config | sed '/^Host /!d;s/Host *\([^ \#]\+\)/\1/') } +SSH_HOSTS=($([[ -f $HOME/.ssh/config ]] && print -n $(cat $HOME/.ssh/config | sed '/^Host [^*]/!d;s/Host *\([^ \#]\+\)/\1/' | sort))) -zstyle ':completion:*:ssh:*' hosts $(list-ssh-hosts) -zstyle ':completion:*:scp:*' hosts $(list-ssh-hosts) +zstyle ':completion:*:ssh:*' hosts $SSH_HOSTS +zstyle ':completion:*:scp:*' hosts $SSH_HOSTS zstyle ':completion:*:ssh:*' users # disables users completion zstyle ':completion:*:scp:*' users # disables users completion