Mac – How setup macports package bash to be used from terminal.app

bashmacportsterminal

I've made a bit of confusion trying to make terminal.app use /opt/local/bin/bash installed from macports as shell.
I've used:

chsh -s "/opt/local/bin/bash --rcfile ~/.profile -v"

trying also with -l option but still do not reads ~/.profile.
I've set also

/opt/local/bin/bash --rcfile ~/.profile -v -l

in terminal.app preferences.
Any suggestion to correctly set up terminal.app to use /opt/local/bin/bash and to load ~/.profile?
Thanks

Best Answer

From man chsh

The shell field is the command interpreter the user prefers.  If the shell field
is empty, the Bourne shell, /bin/sh, is assumed.  When altering a login shell, and
not the super-user, the user may not change from a non-standard shell or to a
non-standard shell.  Non-standard is defined as a shell not found in /etc/shells.

So to change your shell to /opt/local/bin/bash run

grep -q '^/opt/local/bin/bash' /etc/shells || sudo sh -c 'echo /opt/local/bin/bash >> /etc/shells'
chsh -s /opt/local/bin/bash

If you use bash as your login shell (which is what chsh and the default for Terminal.app do) then if you don't have ~/.bash_profile then bash will automatically read ~/.profile (but as you are using bash you should be using ~/.bash_profile)

Terminal.app by default runs login which runs the shell set by chsh and that should be loading macports bash and then ~/.profile