macOS

Updating Your Shell

If you haven't manually updated your version of Bash or Zsh on OS X, chances are it’s out-of-date. Here’s how to install the latest version and keep your shell updated using Homebrew.

OS X ships with an outdated version of Bash as its default shell. The preinstalled version dates back to 2007, and since then, Bash has been updated to add features and fix troublesome bugs. If you want to use an updated version of Bash—or even Zsh—as your shell, you can install it by using Homebrew, a package manager for OS X.

Installing via Homebrew

Whether you prefer using Bash or Zsh, the following instructions will work for both. Just change the word bash to zsh, and you’ll be good to go.

Open your terminal and enter:

brew install bash

Setting up

Homebrew installs packages to /usr/local/, some packages are linked so you can use them right away, others are not. So we’ll need to specify that package's path when looking for a specific program.

To set the newer bash as default type:

sudo -s
echo /usr/local/bin/bash >> /etc/shells
chsh -s /usr/local/bin/bash

That's it! Now you can close and reopen your terminal to start using the new version of bash.

Double-check the version you’re using with the command:

echo $BASH_VERSION

Or, if you’ve installed Zsh:

echo $ZSH_VERSION

To check the version without login into the shell do this.

  mteam7 [~] $ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.

The above is the bundled bash that ships with Sierra. And here is brew's bash:

  mteam7 [~] $ /usr/local/bin/bash --version
GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin15.6.0)
Copyright (C) 2019 Free Software Foundation, Inc.

 

© 2019 Mteam7 - All rights lorem ipsum dolor sit amet, consectetur adipiscing elit.*