Enable bash completion in macOS

macOS by default does not have Bash autocomplete feature at the terminal by default as Linux distributions like Ubuntu does. To enable it, you will have to install and enable bash-completion program for macOS which is available via Homebrew.

Follow these steps at the Terminal to have autocomplete feature in Bash for your macOS:

  1. Install Homebrew by running the following commands.
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install bash-completion via Homebrew.
    $ brew install bash-completion
  3. Manually enable bash-completion for current session.
    $ . /usr/local/etc/bash_completion
  4. 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

Sign up for Mac OS X Superuser - Use Mac OS X like a Pro and many other great courses on Udemy to learn more.

Mac OS X Superuser - Use Mac OS X like a Pro

Mac OS X on steroids. Learn to Move Around OS X and Automate Common Tasks!

Written by Mohd Shakir Zakaria. Last updated on 2019-03-25