Installing bash on macOS
A quick post on how to install bash on macOS to replace zsh.
Why did Apple stop shipping with bash? Licenses. The older version of Bash was licensed under GPLv2, while newer versions are licensed under GPLv3.
Installing bash
Run the following command to install bash:
1brew install bash
2/opt/homebrew/bin/bash --version
Add the newly installed shell to /etc/shells
1sudo vi /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
Run the following command to change the default shell:
1chsh -s /opt/homebrew/bin/bash
Restart the terminal and run the following commands to validate it.
1echo $SHELL
2echo $BASH_VERSION
Note:
bash --versionmay still give us an older version number. Check the$PATH; there’s a chance/bin/bashis still listed before the new shell’s path, but it does not mean that we’re using an older bash version. Useecho $BASH_VERSIONto confirm this. See https://stackoverflow.com/questions/72893657/unable-to-set-bash-5-1-as-default-on-mac for more details.
Use ~/.bash_profile to configure our new shell.
Happy coding.
