I have tried the examples found here to get Git auto-completion working on El Capitan, however none of the examples work for me.
I installed bash-completion
with Homebrew (brew install bash-completion
).
This is my ~/.bash_profile
currently (as you can see, i've tried a few things):
CRMPiccosMacBook:etc crmpicco$ cat ~/.bash_profile
alias ll='ls -lG'
alias composer="php /usr/local/bin/composer.phar"
#if [ -f $(brew --prefix)/etc/bash_completion ]; then
# . $(brew --prefix)/etc/bash_completion
#fi
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
#source /usr/local/git/contrib/completion/git-completion.bash
#GIT_PS1_SHOWDIRTYSTATE=true
#export PS1='[\u@mbp \w$(__git_ps1)]\$ '
So, if I go into my directory with the cloned Git repo and type git checkout m
and hit [TAB] I get nothing (when expecting master
to be pre-filled).
When I run a source
on it, it doesn't exist – however it's installed.
CRMPiccos-MacBook:signup crmpicco$ brew install bash-completion
Warning: bash-completion-1.3_1 already installed
CRMPiccos-MacBook:signup crmpicco$ source /etc/bash_completion.d/git-completion.bash
-bash: /etc/bash_completion.d/git-completion.bash: No such file or directory
Best Answer
You are confusing the basic bash completion with the add on required for completing git commands.
The
git
that is installed by Apple lacks the requiredgit-completion.bash
file so you need to install the full git. You can do this easily with homebrew -brew install git
will do the job.Once you've done that then uncomment your top three lines :-
Now
source ~/.bash_profile
and it should work fine.