Upgrade bash on Mac OS X Mavericks

Yesterday, I learned quite a lot about different kinds of shells in terms of history, developer, current state and etc. I decided to use bash as my main terminal shell with no hesitation after my researches. However, I found that my bash was of a really old version on my mac. I decided to upgrade it. Here is how I did it.

  1. Install Homebrew, which is a package manager for Mac OS X. It can help to install a lot of useful packages that are omitted by Apple.

    ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

  2. Use Homebrew to install the newest version of bash (4.2.45)

    brew install bash

  3. The executable file will be placed under /usr/local/bin/bash, so add /usr/local/bin/bash to /etc/shells by your favorite text editor. Don’t forget to use sudo.

    sudo vi /etc/shells

  4. Change your shell

    chsh

  5. Change the line that has Shell to the location that your newly brew installed bash is located.

    Shell: /usr/local/bin/bash

  6. Restart your terminal

  7. Verify the version of your bash shell

    echo $BASH_VERSION