Programming

While typing in a terminal, tab completion is a huge time saver. Being able to auto-complete file names or commands is very nice, especially if you can’t quite remember what it is.

There are times, however, that this has become quite annoying for me as a developer. More than once a day when I really get in the zone and start hacking, I will accidentally hit tab when I have not yet input anything. While this doesn’t slow things down too much for me on a native Linux installation, it causes a huge delay when using Cygwin. Instead of just quickly asking me if I want display all the options, it appears to start to build the command list which has a delay of many seconds. This completely breaks my flow of programming.

I’m not entirely sure if it has to do with the number of possible auto-completes in my Cygwin installation or if it just is slower than a Linux installation but I didn’t want it anymore. I never find myself just hitting tab to get the list of every possibility; I am always auto-completing.

Having searched online before for a solution but never coming up with anything I just sort of accepted that my flow would be interrupted every once in a while by this silly behavior. Today, I ran into the issue multiple times and decided I had, had enough. I hopped into ##linux on Freenode.

There, I was delivered the option that would make my problem go away:

shopt -s no_empty_cmd_completion

Dropping this line in my ~/.bashrc file accompanied by a quick restart finally made my problem go away.

Much better.

If you liked this post, then please consider following me on Twitter or subscribing to my feed.

  • Amit Gurdasani

    I’ve been looking for a solution to the empty tab complete for a while now. Thanks for sharing the solution with the world! Cygwin’s had to kludge around the impedance mismatch between Win32/Win64 and POSIX, and that leads to odd behaviors and corner cases. This was easily the most irritating one.

  • Jiashu Zou

    Thank you very much! I’ve been searching the web for days with no luck.