Enable auto-complete functionality to your Mac OS terminal

This is a really big time saver and helper when you don’t remember which is the name of the parameter that you need, so in order to enable it you just need to do the following.

brew install bash-completion

And then add the following lines to your ~/.profile file

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
if [ -f `brew --prefix`/etc/bash_completion.d/git-flow-completion.bash ]; then
 . `brew --prefix`/etc/bash_completion.d/git-flow-completion.bash
fi

And restart (actually you can just source the profile but if you can, just restart)

Now you have autocompletion, happy tabbing

And if you don’t, sorry, try the following if after that it still does not work, contact me or comment to fix your problem.

Troubleshooting

Check the existence of the files

That the files git-completion.bash and git-flow-completion.bash exists in the directory, if they don’t well provide them manually (one time I needed to made this), you can download the files from:

git-completion.bash
git-flow-completion.bash

You can find the folder where they need to be running brew –prefix and appending to that response /etc/bash_completion.d/ so you can run a command like

cp ~/Downloads/git* $(brew --prefix)/etc/bash_completion.d/

Repair brew

Well after a while using brew some things start to get real messy, so clean up things running

brew doctor

That command will not actually do “automatically” something, it informs you if there is conflicts and says how to solve them (that is already doing something big), so make the things that you need to do and run it again until there is everything ok

After that run

brew prune

This one removes old linked things

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s