How to prevent ZSH from taking 10+ seconds when using autocomplete with zypper?

When I use zsh and type sudo zypper install then TAB, zypper is launched and I cannot intereact with the shell for up to 30 seconds sometimes, the fix I was using was zstyle ':completion:*:zypper:*' use-cache on but that is no longer working.

I am wondering how I can make it work instantly like in bash

Find out what zsh does differently, submit a fix or at least a bug report.

I had the same problem, but it was related to the enabled option:
ENABLE_CORRECTION="true"
in my ~/.zshrc config. I just commented it out and the autocomplete started working fast, just like before.

so the issue was it was generating the cache whenever autocomplete was called so i made it pre-generate the cache when the shell is launched.

add this to your .zshrc

function zypper_prepare_cache(){
  _zypp_all_raw=$(zypper -x -q --no-refresh se | grep '<solvable' | cut -d \" -f 2,4) 
  _zypp_all=($(echo $_zypp_all_raw | grep 'installed' | cut -d\" -f 2)) 
  _zypp_not_installed=($(echo $_zypp_all_raw | grep 'not-installed' | cut -d\" -f 2 )) 
  _zypp_installed=($(echo $_zypp_all_raw | grep '^installed' | cut -d\" -f 2 )) 
  _store_cache ZYPPER_ALL_RAW _zypp_all_raw _zypp_all _zypp_not_installed _zypp_installed
}
(&>/dev/null zypper_prepare_cache & )

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.