In the world of command-line interfaces, auto-completion can be a boon for productivity. Bash completion is a functionality provided by the bash shell, which offers context-aware auto-completion of commands and their arguments.

For developers and system administrators who frequently utilize the command line on macOS, bash completion is a feature that can save a significant amount of time. Older macOS versions come with bash as the default shell, but unlike Linux distributions, bash completion isn't enabled out-of-the-box.

However, with a little configuration and the assistance of the package manager Homebrew, you can effortlessly enable bash completion and make your command line experience smoother on your macOS system.

Steps to enable bash completion in macOS:

  1. Launch Terminal.
  2. Install Homebrew by running the following commands.
    $ /usr/bin/ruby -e "$(curl -fsSL"
  3. Install bash-completion using Homebrew.
    $ brew install bash-completion
  4. Manually enable bash-completion for current session.
    $ . /usr/local/etc/bash_completion
  5. Automatically enable bash-completion when launching a new shell session by adding the following lines to ~/.bashrc or ~/.bash_profile.
    [ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
  6. Test the bash completion by typing a command and pressing the Tab key.
Discuss the article:

Comment anonymously. Login not required.