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 have bash-completion installed using macports and following lines in my .bash_profile

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

but the completion doesn't work when I open Terminal, however it starts working after sourcing .bash_profile or after 'bash -l'.

I'm running OSX 10.6, in Terminal preferences there is "Shell opens with: Default login shell (/usr/bin/login)" selected.


Solved: What I missed is line in How to use bash-completion

Make sure you add this after any PATH manipulation as otherwise the bash-completion will not work correctly.

when I moved the lines after PATH manipulation everything works fine.

share|improve this question

1 Answer 1

I'd use the chsh command to make sure your shell is actually Bash; if your shell is /bin/sh instead of /bin/bash, Bash will mimic a historical shell, and won't read ~/.bash_profile.

From man bash:

If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or a non-interactive shell with the --login option, it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order.

[...]

Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect.

share|improve this answer
1  
The account's default shell can be changed in System Preferences » Accounts » Right-click your entry » Advanced…. It's /bin/bash by default. –  Daniel Beck Apr 1 '11 at 5:52
1  
My shell is '/bin/bash' and the '~/.bash_profile' is read, everything (aliases, prompt) but bash completion works fine. –  liborw Apr 1 '11 at 7:23
    
@Daniel: Thanks, I wasn't sure if the default shell had changed since 10.4. @liborw: Can you make your full ~/.bash_profile available? Editing the information from your last comment into the original post would be helpful as well. –  lewist Apr 1 '11 at 19:59

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.