Home » Odeon Blogs » Stefan Talpalaru, CTO »

upgrading bash on OS X

upgrading bash on OS X

If you've noticed that the bash that comes with OS X is outdated and you're bothered by it, this post is for you. First, install macports if you don't have it already. Open a terminal (I prefer iTerm but the default one will do just fine) and get a root shell:

  1. $ sudo -s
Install bash:
  1. # port -cv install bash
Add it to the list of allowed login shells
  1. # echo /opt/local/bin/bash >> /etc/shells
Now you can switch to it for any account by running:
  1. chsh -s /opt/local/bin/bash
and get a nice prompt, export global variables, define aliases, function and whatnot in a $HOME/.bashrc file. Feel free to use mine if you want.

In order to load your .bashrc automatically on each terminal tab you need to do one more thing (as root):
  1. # chmod u+w /etc/bashrc
and at the end of /etc/bashrc add this line:
  1. [ -f "$HOME"/.bashrc ] && . "$HOME"/.bashrc
Finally, you can start a new terminal session, echo $BASH_VERSION and be smug about it ;-)


Category: OS X

Discussion

  1. sam on Mar 28, 2011 - 12:06 said:

    the same is possible with brew

    brew install bash

    it will be installed in:
    /usr/local/Cellar/bash/4.2.8/bin/bash

    but one last step is missing. to be sure the new bash is used an update on $PATH is needed

    export PATH=/usr/local/Cellar/bash/4.2.8/bin/bash:$PATH

    this will allow you now to use bash --version :-)


  2. Thanks, sam.
    The version number in the PATH doesn't look right. How about adding /usr/local/bin instead? I think that homebrew already creates a symlink there for installed packages.


  3. sam on Mar 30, 2011 - 0:41 said:

    hey stefan,

    good point. i didn't checked /usr/local/bin yet.




Leave a Comment :

(required)


(required)




(required)




(required)






Leave a Comment


Page generated in: 0.21s