zsh autocomplete slow for ssh

▼魔方 西西 提交于 2021-01-05 06:29:59

问题


I upgraded my macbook to OSX Catalina recently. Ever since that upgrade my zsh autocomplete (tab completion) for ssh is really slow (previously, it was reasonably fast, e.g. autocomplete would happen in a few seconds). Some details that I think are relevant:

  1. I have a ~/.ssh/config file with ~2000 hosts configured
  2. When I type ssh x <TAB> things seem to hang, typing ctrl-C says Killed by signal in _ssh_hosts after 22s so it seems that my _ssh_hosts script is the problem

Any tips on how to debug this? Or alternate _ssh_hosts function I could use?


回答1:


I've put together a solution that works for me using zstyle thanks to this email thread

My solution was to make my ~/.zshrc contain the following

function refresh_ssh_autocomplete () {
    host_list=($(cat ~/.ssh/config | grep 'Host '  | awk '{s = s $2 " "} END {print s}'))
    zstyle ':completion:*:(ssh|scp|sftp):*' hosts $host_list
}
refresh_ssh_autocomplete



来源:https://stackoverflow.com/questions/59940971/zsh-autocomplete-slow-for-ssh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!