Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I read a bunch of instructions for installing bash-completion for git, and settled on the macport solution, which is, for example, mentioned here: How to get git-completion.bash to work on Mac OS X?

However, this does not work, and I must call source /opt/local/etc/bash_completion.d/git or put it in my .bashrc to activate git bash completion. Am I missing something? It seems like sourcing of a specific completion package should be more automatic, and no one on the web that I've found has listed this in their instructions for getting git bash-completion to work on mac os.

share|improve this question
up vote 5 down vote accepted

MacPorts' bash-completion script is supposed to live at /opt/local/etc/bash-completion and take care of sourcing everything inside /opt/local/etc/bash-completion.d/*. However, it is not installed by default. You need to...

sudo port install bash-completion

...and then you still need to source /opt/local/etc/bash-completion from one of your bash startup scripts.

Note that the latest version of that script requires bash >= 4, which is later than is included with Mac OS X Lion 10.7.x (which includes bash 3.2.48(1)). Update: OS X Mountain Lion v10.8.0 still appears to ship with bash 3.2.48(1), so this step is still needed even on Mountain Lion. So make sure you've installed a later bash with MacPorts, and make sure you've configured (or whatever terminal you're using) to run /opt/local/bin/bash instead of OS X's default /bin/bash.

See also (recommended reading! good tips!):

share|improve this answer
Changing terminal to run /opt/local/bin/bash resolved it. Can you tell me why this step is needed? – jonderry Jul 17 '12 at 16:50
@jonderry That step is needed because the guys who maintain the bash-completion scripts have chosen to use features that are only in bash 4.x, and thus require bash 4.x, but OS X Lion only includes the older bash 3.2.x. If you look at /opt/local/etc/bash-completion, it explicitly checks your bash version before proceeding. – Spiff Jul 17 '12 at 18:51
Is that still the path? /opt/local/etc/profile.d/ ? – Clayton Stanley Jul 18 '12 at 4:10
@claytontstanley Yes, the path I listed appears to be a more convenient symlink to the path you listed. – Spiff Jul 18 '12 at 5:42
Bash tip for works great, thanks... – plang Aug 2 '12 at 21:29

Your Answer


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.