Skip to content

bash-completion

Bash Command for Developer

Bash Completion

Reference

Bash completion is a bash function that allows you to auto complete commands or arguments by typing partially commands or arguments, then pressing the [Tab] key. This will help you when writing the bash command in terminal.

Installation

Terminal window
brew install bash-completion

Bash completion will be installed in /usr/local/etc/bash_completion.d. For it to work, add this to your ~/.bash_profile:

Terminal window
echo "[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion" >> ~/.bash_profile

Restart your bash session:

Terminal window
source ~/.bash_profile

More

You can list additional completion packages are available by typing:

Terminal window
brew search completion

And you can install them using brew install commands, for example:

Terminal window
brew install docker-completion

You can also manually add a bash completion file into /usr/local/etc/bash_completion.d