DEV Community


Awesome Terminal upgrades - Part One: Upgrade and use a newer version of BASH on macOS

0xdonut profile image Mr F. Updated on ・2 min read

This is part one in the "Awesome Terminal upgrades" series. In this short tutorial we will cover BASH on macOS and how you can upgrade and manage it using Homebrew.

Install Homebrew

The missing package manager for macOS (or Linux)

We will be using Homebrew to manage everything for us, if you don't have it installed, go ahead and do it now!

echo “[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion” >> ~/.bash_profile

Upgrade and use a newer version of BASH on macOS

As of macOS Catalina, the default shell is set to ZSH.
The default version of BASH on macOS is 3.2 which is ancient!
We'll be installing and using version 5 and making it our default shell instead.

brew install bash
sudo vim /etc/shells

You’ll see some output that looks like this:


We need to update it:

  1. Use your keypad to go down to the last line and press i to edit this line
  2. Type in /usr/local/bin/bash
  3. Type :wq to writeout the file and quit.

Change your default shell to BASH

sudo chsh -s /usr/local/bin/bash

After that, restart your Terminal to have it take effect.

Make sure BASH knows where to source everything from

In order to make sure all of the above stick and work whenever you fire up a terminal, add this line to the top of your ~/.bash_profile file.

[ -r ~/.bashrc ] && . ~/.bashrc

Awesome, your shell is now using BASH managed by Homebrew!
You can update BASH whenever you like, as well as you other Homebrew installs by running:

brew update && brew upgrade

Discussion (2)

Editor guide
gabrielizalo profile image
Gabriel Porras

Does this apply to Ubuntu? Thanks

0xdonut profile image
Mr F. Author

I wouldn't use Homebrew on Ubuntu. You are better off using the native apt-get instruction, a quick google search returned this article