[X-Unix] .profile v/s .bashrc
Juan Manuel Palacios
jmpalaciosp at eml.cc
Wed Oct 13 17:41:14 PDT 2004
On Oct 13, 2004, at 6:03 PM, Alexandre Quessy wrote:
> Hi!
>
> 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 ?
>
> Thanks.
>
> Alexandre Quessy
> PHP, etc. in Montréal
Hi Alexandre! Short answer with snippets of my files (note, I don't
know if the way I set things up is recommended, but I haven't seen any
problems thus far):
$[juan at PowerBook: netwox](444/0,1)-> cat ~/.bash_profile | head -20
######
## User specific bash environment variables.
## Created by Juan Manuel Palacios,
## email: jmpalacios at ml1.net
######
# If we haven't read ~/.bashrc and ~/.profile lets do it now,
practically everything is defined there:
if [ -f ~/.profile ]; then
. ~/.profile
fi
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
---snip---
$[juan at PowerBook: netwox](446/0,1)-> cat ~/.profile | head -15
######
## Personal profile for bourne based shells (see also /etc/profile).
## Created by Juan Manuel Palacios,
## email: jmpalacios at ml1.net
######
# If we haven't read system wide profile lets do it now...
if [ -f /etc/profile ]; then
. /etc/profile
fi
---snip---
$[juan at PowerBook: netwox](447/0,1)-> cat ~/.bashrc | head -15
######
## User specific bash initialization file.
## Created by Juan Manuel Palacios,
## email: jmpalacios at ml1.net
######
# If we haven't read /etc/bashrc lets do it now:
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
---snip---
So, by doing this, if I span a login shell and every referenced file
exists everything in them will be loaded; on the other hand, if I span
a non login shell all I have to do to load my settins (a la login
shell) is 'source ~/.bash_profile', every file will be read. So,
bearing that, you can put whatever you want wherever you want,
permissions allowing of course.
Hope that helps! Regards,...
Juan
More information about the X-Unix
mailing list