ok, so I needed the git autocompletion script.
I got that from this url:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
No need to worry about what directory you're in when you run this as your home directory(~
) is used with the target.
Then I added to my ~/.bash_profile
file the following 'execute if it exists' code:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
Update: I'm making these bits of code more concise to shrink down my .bashrc
file, in this case I now use:
test -f ~/.git-completion.bash && . $_
Note: $_
means the last argument to the previous command. so . $_
means run it - "it" being .git-completion.bash
in this case
This still works on both Ubuntu and OSX and on machines without the script .git-completion.bash
script.
Now git
Tab (actually it's git
TabTab ) works like a charm!
p.s.: If this doesn't work off the bat, you may need to run chmod u+x ~/.git-completion.bash
to grant yourself the necessary permission:
chmod
is the command that modifies file permissions
u
means the user that owns the file, by default its creator, i.e. you
+
means set/activate/add a permission
x
means execute permission, i.e. the ability to run the script
I don't know if this will populate in the terminal / advanced user account locations, but "The Way This Has Worked For Years"™ in Linux-land is that you must update /etc/shells
with the path to the shell location, and then use chsh -s /usr/local/bin/bash username
to use it.
Simply running chsh
without modification to /etc/shells
should cause an error indicating you've chosen an invalid shell, in case you're curious.
/etc/shells
is a root-owned file, so you must use sudo in tandem with an editor in order to modify it. I hope you're comfortable doing that, else I would highly advise against trying out a non-default shell :).
Summary (steps):
brew install bash
, then
sudo vi /etc/shells
and add /usr/local/bin/bash
to the list, then
chsh -s /usr/local/bin/bash [your_username]
and restart your terminal in order for your changes to take place
Best Answer
I solved this by adding the following to my
.bash_profile