Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I don't understand why bash completion is loaded so slow on my MacBook Pro.

I did the following in my ~/.bash_profile:

echo "Loading BashCompletion..."
if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi
echo "BashCompletion loaded."

the execution time for bash_completion typically is > 2 seconds.

I find that really annoying when I am working on the terminal which requires me to constantly open new tabs.

Is there a way I can cache this or something?

(Note I am using iTerm2 and this is equally slow on the original terminal in Mac as well).

share|improve this question
    
That should not be happening. Am I correct you use MacPort's bash completion? –  slhck Jul 15 '11 at 20:27
    
What does that file you load look like? –  Daniel Beck Jul 15 '11 at 20:48
    
@slhck: Yes I am indeed using macport's bash completion –  disappearedng Jul 15 '11 at 21:17
    
@Daniel: Everything is fine except for this. I profiled almost every line. –  disappearedng Jul 15 '11 at 21:17
4  
I experience the same slowness and I'm using Homebrew. –  Brice Jan 30 '12 at 11:52
show 3 more comments

2 Answers

If you're running MacPorts >= 2.1.2 and Mountain Lion it seems your bash_profile is wrong. Follow the instructions on How to get git-completion.bash to work on Mac OS X?. I assume that could speed up the auto-completion.

Another solution would be to try installing auto-complete via Fink or Homebrew. If that doesn´t work, you could try another shell altogether. I've found that Fish shell is outstanding when it comes to auto-completion (out of the box). Though version 2 is still in beta I would highly recommend it.

share|improve this answer
add comment

I'm going to guess that your bash is too old. I'm running stock bash that came with Mountain Lion and here's what I see:

$ port info bash-completion
bash-completion @2.0, Revision 1 (sysutils)

Description:          Programmable completion library for bash. This port
                      **requires bash >=4.1** and is meant to be used together with
                      the bash port.
Homepage:             http://bash-completion.alioth.debian.org/

Runtime Dependencies: bash
Conflicts with:       bash-completion-devel
Platforms:            darwin
License:              GPL-2+
Maintainers:          raimue@macports.org

$ bash --version
GNU bash, version **3.2.48(1)-release (x86_64-apple-darwin12)**
Copyright (C) 2007 Free Software Foundation, Inc.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.