keyboard-shortcut
d

using a non-default shell

3min read

an image

Default Shell

You can view your default shell with the following commands (examples included are for bash and zsh but you can use whatever you prefer):

  • which bash
  • which zsh
  • cat /etc/shells

Installing a new shell

You can install new shells using your preferred package manager. As a mac user I typically use brew:

  • brew install bash
  • brew install zsh

Using your preferred shell

To switch the default shell you will need to find where your shell is installed. Using brew you can run:

  • brew info bash and parse the output for anything starting with /opt/...

To use your new preferred shell, you can simply add it to the end of the your can simply add it to the end of your /etc/shells file:

  • echo '/opt/homebrew/bin/bash' >> /etc/shells
  • echo '/opt/homebrew/bin/zsh' >> /etc/shells

Checking your preferred shell

To check which shell is configured you can run echo $SHELL either in your default terminal prompt (in my case zsh) or in a new prompt (to run "bash" I can simply execute it with bash)

Why bother?

The "default" shell is often tied to your laptop's default shell. This can often be incredibly out of date! Before these steps bash --version gave me version 3.2. After running these steps, the same command gave version 5.2.

Detaching your terminal from the default prompt should give you the best performance, security and functionality.

The reason for me doing this was that I noticed that I didn't have access to the mapfile command. How helpful!! 🚀