For a week now, opening a new tab or window in OS X’s Terminal application has been major palaver, sometimes taking up to a minute. CPU usage would shoot up (mostly/usually by WindowServer, but sometimes by kernel_task). It was driving me nuts. I practically live in the Terminal (or the be more accurate, Terminal + Vim), and usually spawn a new Terminal window several times in an hour for everything from using R as a calculator to opening files for viewing to actual development work. With this slow down, I found myself sometimes literally screaming in frustration: I would flick the hot key that I had bound to spawn a new Terminal window and start typing, only to realize after a half dozen characters that I might as well be watching cat videos on the internet because the window had not finished opening.
Of course, the natural suspect was my ‘~/.bashrc. It is about 1500 lines long, and, moreover sources other files. But this has been the case for years, and while I am constantly tweaking it, I could not recall making any changes in the days preceding the slow-down. More to the point, temporarily disabling this had absolutely no effect at all. Terminal still opened new windows at a tectonic pace.
I was musing reinstalling the operating system (or moving to Lion), when I stumbled upon this post:
Basically, log files build up in ‘/var/log/asl’, and this baggage causes Terminal to go catatonic during launch. Cleaning out the directory:
$ sudo rm -r /var/log/asl/*
Terminal now opens new windows and tabs instantly, 1500+ line ‘.bashrc’ and all, and I am back to spawning shells as wantonly and profligately as before!