You're looking for:
brew install git bash-completion
As warpc's comment states, you'll need to add the following to your ~/.bash_profile
to get homebrew's bash-completion working:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
The above is mentioned in the caveats when you install the bash-completion formula.
Note: if you are using Bash v4 or later (via brew install bash
) then you're going to want to use brew install bash-completion@2
, to enable tab completion add the following to ~/.bash_profile
as described in the caveats:
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
The additional export is necessary for git, docker, youtube-dl, and other completions which may be included in the $(brew --prefix)/etc/bash_completion.d/
directory.
This get's git tab completion working on OSX without having to restart your terminal:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
echo "source ~/.git-completion.bash" >> ~/.bash_profile
source ~/.bash_profile
EDIT: this doesn't work in Catalina's default zsh shell. I changed the default shell back to bash and it works again. https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/
In case anyone else makes my dumb mistake, try brew install git
. I was using the git
that comes with Xcode and didn't realize that I had never installed Homebrew's git to get the autocompletions.
for some reason I was missing the file at $(brew --prefix)/etc/bash_completion
so @Graham Perks' correct answer didn't work for me
It ended up the fix in my case was:
brew unlink bash-completion
brew link bash-completion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With