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