Pages

Update bash shell for Mac OS X

Apple releases software update quite often but, unfortunately, bash shell is never updated. The version of bash shell that comes with Max OS is quite old and lacks many features such as globing, exclude-dir when grepping, etc. If you need these features, you will need to update bash shell. First, check the version of your bash.


$ echo $BASH_VERSION
3.2.53(1)-release

$ which bash
/bin/bash

Now, use brew to install latest version of bash, 4.3 at this time of writing.



$ brew install bash

$ which -a bash
/bin/bash
/user/local/bin/bash

Notice that there are 2 versions of bash now. The new one installed by brew is at /user/local/bin/bash. The default bash shell is still the one at /bin/bash. We need to tell the system to switch to the new one.



$ echo /usr/local/bin/bash >> /etc/shells

$ chsh -s /usr/local/bin/bash

The first command adds the new bash shell into /etc/shells, which contains the list of all available shells. The second command change shell (chsh) to the new one that we've just installed.



$ echo $BASH_VERSION
4.3.30(1)-release

$ which bash
/user/local/bin/bash

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Node JS Online Training from India . or learn thru Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Online Training

    ReplyDelete