Solved: ZSH tab completion painfully slow

Soooo slow

First, I love zsh. It has a bunch of features that bash doesn’t so I’ve been using it as my main shell for about three years.

That said, it hasn’t been all great. Some time ago, I came across a major issue that almost made me stop using zsh. Basically, for sufficiently large projects, git tab completion was taking longer and longer. At first, it was a few seconds which, while annoying, wasn’t fatal. Then it got worse and worse. This morning, if I had a file named foo.html and I typed git diff fo and hit tab, the command line would lock for up to 30 seconds, leaving me unable to do anything.

I had, in the past, spent some time searching and found a handful of pages in the zsh developer mailing lists discussing the problem as a known issue, but offering no solution. Some pointed to the way compinit recursively does things, others had other explanations, but no one offered a solution. There were technical grumblings about how it’s a hard problem to solve, blah blah. I’m not saying it isn’t a hard problem to solve, but it’s pretty ridiculous that it isn’t solved. In bash, this kind of thing is basically instant, there should be no way that they can’t find some solution.

Bottom line, I no longer cared, I just wanted my freaking command line to not go unresponsive for such a long time.

The solution

I found the solution here. It was relatively simple, just replace the zsh _git with that version. And voila, all seems to work! Literally years of frustration seem to have vanished. I’m writing this hopefully to publicize it so more people are able to find the solution to this painful problem.

Published 22 Dec 2011

Scaling and leading engineering and data teams to solve the world's problems
Victor Quinn on Twitter