[X-Unix] .profile v/s .bashrc

Eugene list-themacintoshguy at fsck.net
Wed Oct 13 15:23:15 PDT 2004


On Wed, Oct 13, 2004 at 06:03:18PM -0400, Alexandre Quessy wrote:
: 
: I want to access my aliases wherever I am I'm my shell. So, I wrote 
: them in my $HOME/.profile file. But there is a problem.
: 
: When I first log in, it's my « .profile » that is executed. If i change 
: my shell to zsh, for instance, and then I switch back to bash, it's my 
: « .bashrc » that is executed and my aliases that were set in the 
: « .profile » aren't available anymore. Is there a workaround so that my 
: aliases are always availables ?

Like most shells, bash reads and executes a different series of scripts
depending on whether your interactive shell is also a login shell or not.

If it's a login shell, bash first looks for /etc/profile.  Then, it
looks for ~/.bash_profile, ~/.bash_login, and ~/.profile; it reads
and executes the first file it finds.

If it's not a login shell, it looks for ~/.bashrc.

What I usually do is put most of my bash-specific settings inside
~/.bashrc, then set my ~/.bash_profile to "source $HOME/.bashrc".


-- 
Eugene Lee
http://www.coxar.pwp.blueyonder.co.uk/


More information about the X-Unix mailing list