Possible Duplicate:
Bash completion for commands in Mac OS

I'm just moved from linux to mac, and one of the problems I'm having is that tab completion is only 1 level deep, and I'm not sure how to correct that.

Let me explain by example - when I used git on ubuntu, I'll start typing

$ git

and hit tab, and the shell would complete the command or display the options available for the letter\s I've typed. That's what happens on my mac as well (1 level). However, when I'd continue typing the next part of the command

$ git commit

and hit tab, mac terminal would not complete the next subcommand (for git) as it would in Linux. Same goes for other programs that support this multilevel command completion. I suspect this might be a readline library issue, but I'm not sure which one I should install.

marked as duplicate by slhck, Daniel Beck, Ivo Flipse Jul 14 '12 at 13:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Oct 11 '09 at 18:54

This question came from our site for professional and enthusiast programmers.

  • It is not a readline issue (in fact, it is not an "issue"), it is because Ubuntu holds your hand with custom packages for bash. – Jed Smith Oct 11 '09 at 18:37
  • This is definitely a bash configuration issue (since I get this behavior on mac + alot more that I have configured it for, like hostname completion) You should look around for power scripts for bash and add them to your profile. – Shane C. Mason Oct 11 '09 at 18:49

Download bash_completion and source it from your .bashrc. Then put contrib/completion/git-completion.bash from the git distribution into bash_completion.d.

Alternatively you can install it via MacPorts.

  • thanks, this worked. I added the following in my .bashrc if [ -f /opt/local/etc/bash_completion ]; then source /opt/local/etc/bash_completion fi – sa125 Oct 11 '09 at 20:02
  • 1
    Even better, install it via homebrew: brew install bash-completion – abyx Nov 23 '10 at 7:40
  • @abyx: chosing the "better" between homebrew and macports is a very subjective thing – user13898 May 4 '11 at 15:18

For git there is an option available on compilation to support completion.

If you used port to install Git (which I recommend), you can reinstall git with this command

sudo port install git-core +svn+bash_completion+doc

Which will install git with bash completion, git-svn support and docs

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