Skip to content

Instantly share code, notes, and snippets.

@MaximBazarov
Last active September 6, 2018 21:01
Show Gist options
  • Save MaximBazarov/6c35aeb4b2460fbe9a4094c344f5acb9 to your computer and use it in GitHub Desktop.
Save MaximBazarov/6c35aeb4b2460fbe9a4094c344f5acb9 to your computer and use it in GitHub Desktop.
Mac OS, terminal history based commands autocompletion
  • Make sure you have Homebrew installed, and then use it to install the package bash-completion (by typing the command brew install bash-completion).
  • Homebrew should now tell you what you need to do to complete the installation. In this case, you need to add these three lines to your .bashrc file (using either a command-line text editor like nano which we used above, or a graphical one):
if [ -f $(brew --prefix)/etc/bash_completion ]; then
   . $(brew --prefix)/etc/bash_completion
fi
  • You should now have auto-completion in bash. Please note: for the changes to take effect in existing shells, .bashrc will need to be sourced. Alternatively, logout and login again, or just reboot.

  • To disable it, all you need to do is remove the lines we added above, and run the command brew uninstall bash-completion --force.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment