Wednesday, April 1, 2009

Slow-Opening Terminal Windows

/usr/libexec/path_helper, which Mac OS X runs every time a login shell is created, is really slow. (In particular, I think the slowness is in [[ "$NEWPATH" = *(*:)${p}*(:*) ]].) My Terminal windows were taking about four seconds to open. By removing the files in /etc/paths.d and putting their contents directly into my $PATH in .bash_profile, Terminal windows now load instantly.

11 Comments RSS · Twitter

Stuart Dootson

Thanks - my login shell startup time has gone from noticeable to zero!

I was skeptical, since I only had two files, but it made a big difference to my bash startup time too.

Thanks!

Thank you, I had noticed the slow opening windows on my new work machine, applying this fix makes them open instantly now.

The (sometimes agonizing) delay in opening terminal windows troubles me also.

Reading your tip I went to check out path_helper and found myself puzzled how it could possibly be taking so long. Also:

matt@Siona ~$ time /usr/libexec/path_helper
PATH="/Users/matt/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"; export PATH
MANPATH="/opt/local/man:/usr/share/man:/usr/local/share/man:/usr/X11/man"; export MANPATH

real 0m0.016s
user 0m0.005s
sys 0m0.010s

I don't understand how this can account for such delays when, for me, it runs in <1s.

Can anyone explain?

Matt

Matt: My guess is that this particular pattern match takes exponential time, which is negligible for a short PATH but not for a longer one.

This slowdown is why I always apply this patch to `path_helper`:
http://gist.github.com/123525

Fantastic. So much faster!

This has been bugging me for positively *ages*, and restarting with a completely clean (GUI) login has never helped, but with your fix new shelltabs open instantly. Thank you so much!

Deborah Crittenden

Thanks Martin, that's a very neat solution.

Thank you very much!

Leave a Comment