← Back to list

bash Install & Config

macOS switched to zsh as it’s default shell starting with Catalina, but I still prefer to use bash.

cypherbean · 2022-01-12 02:49 · 0 claps · 2.7 min read
#technology #macos #macports #bash
Open on Medium ↗

bash Install & Config

macOS switched to zsh as it’s default shell starting with Catalina, but I still prefer to use bash. Now that I had MacPorts installed, I wanted to install the latest version of bash and make it my default shell.

[embed]Use zsh as the default shell on your Mac Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the…support.apple.com

Installing the newest version of bash was easy with MacPorts.

MacPorts homepage

MacPorts homepage

MacPorts Available Ports page

MacPorts Available Ports page

Search results for bash

Search results for bash

MacPorts bash page

MacPorts bash page

To install bash using MacPorts, I needed to switch to my admin account using the ‘substitute user’ or ‘su’ command.

Switched to admin account

Switched to admin account

Ran install command

Ran install command

There were 6 dependencies that also needed to be installed.

Install output

Install output

bash version 5.1.16 installed

bash version 5.1.16 installed

To set the newly installed version of bash (opt/local/bin/bash) as the default shell, I needed to add it to the /etc/shells file.

Editing /etc/shells

Editing /etc/shells

Once added to /etc/shells, I ran the ‘change shells’ or ‘chsh’ command to set /opt/local/bin/bash as my default shell.

Ran chsh command

Ran chsh command

To customize my bash prompt, I needed to create a .bashrc file.

Created .bashrc file

Created .bashrc file

The syntax for customizing your prompt in the .bashrc file can be confusing, so I used a .bashrc generator.

[embed].bashrc generator: create your .bashrc PS1 with a drag and drop interface Help To use this for your prompt, it's easy: Type this in your prompt : nano ~/.bashrc Then copy the generated code at…bashrcgenerator.com

Pasted output from .bashrc generator

Pasted output from .bashrc generator

Customized bash prompt

Customized bash prompt

When installing MacPorts, /opt/local/ was added to the $PATH variable of my zsh profile, but now I also needed to add it to the $PATH variable of my bash profile.

To do this, I just copied what MacPorts had written to my .zprofile file and pasted it to my .bash_profile.

Contents of .zprofile that was pasted to .bash_profile

Contents of .zprofile that was pasted to .bash_profile

Confirmed .bash_profile contained $PATH variable information

Confirmed .bash_profile contained $PATH variable information

Bash with custom prompt

Bash with custom prompt

I now had the most up-to-date version of bash set to be my default shell.

What’s your favorite shell to use? Is learning and getting familiar with zsh worth it? Let me know by responding to this post, or you can email me at cypherbean@protonmail.com.


메타데이터
post_id
fef989bc4587
slug
bash-install-config-fef989bc4587
url
https://medium.com/@cypherbean/bash-install-config-fef989bc4587
canonical_url
https://medium.com/@cypherbean/bash-install-config-fef989bc4587
author_url
https://medium.com/@cypherbean
status
ok
fetched_at
2026-07-28 19:11:52