Friday, May 3, 2013

Slow Startup of Cygwin Bash

When on Windows, I never use another terminal/shell than MinTTY/CygWin Bash. So I was heavily harmed by a problem that started quite some time ago: Suddenly, when I opened MinTTY, it took 10 seconds or so, before the bash prompt became visible. Today, I finally discovered the culprit by reading another post. As you posssibly know, there is a directory /etc/profile.d containing scripts that are executed when a login shell is starting. Now, one of these scripts, called bash_completion.sh is extremely slow. You can try for yourself:
$ time . /etc/profile.d/bash_completion.sh

real    0m8.908s
user    0m1.402s
sys     0m7.310s

In other words, solving the issue for me was as simple as renaming this script:
$ mv /etc/profile.d/bash_completion.sh /etc/profile.d/bash_completion.sh.disabled
Voila! My MinTTY opens immediately again. Update: The above time command is only slow when the script is being executed for the first time. In other words, if your bash was starting slow due to executing it, then you might see a result like this:
$ time . /etc/profile.d/bash_completion.sh

real    0m0.000s
user    0m0.000s
sys     0m0.000s