How to Use Homebrew `bash` in Macos




Out of the box, MacOS Sequoia uses an older version of bash, to use an up-to-date version install bash via Homebrew and then set your shell to the Homebrew version.

Install Homebrew bash

brew install `bash`

Locate the Homebrew bash executable

ls "$(brew --prefix)/bin/bash"

On Apple Silicone this will return something like

/opt/homebrew/bin/bash

Preview current list of shells

cat /etc/shells

Which will show a list like

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

Append Homebrew bash to shells list

echo "$(brew --prefix)/bin/bash" | sudo tee -a /etc/shells;

Verify that the append worked

cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/opt/homebrew/bin/bash

Set your shell to the Homebrew version of bash

chsh -s "$(brew --prefix)/bin/bash"

Enter your password when prompted.

Restart your terminal

In order for the new shell to be used, you will have to quit and restart your terminal. Afterward you can verify your new bash version.

echo $BASH_VERSION