If I might qualify this a bit, and based on my understanding ....
.bash_profile is sourced for interactive login shells only (or other
shell started with --login option). .bashrc is not sourced
automatically in such situations (according to my reading of the man
page anyway). But is usually sourced by .bash_profile (which is why I
asked this before). Assuming, this is the case, then yes .bashrc is
always sourced. Interactive shells that are not login shells, and
non-interactive shells source .bashrc only. Also, the system wide
equivalents, of course for both cases.

Where this might cause confusion, is say where you open
terminal apps (rxvt, etc) from the same parent login shell, but these
sub-shells are not login shells. These probably will only source
.bashrc, so having special magic (like aliases) in .bash_profile needs
to be accounted for one way or the other. One way is to do whatever
voodoo is needed to make them login shells. Or have .bashrc do
whatever voodoo when it detects an interactive shell (which might not
be a login shell and thus bash ignores *bash_profile). I do this with:

if [ "$PS1" ]; then
 . ~/.aliases
 . ~/.functions

[...]

This works for the interactive non-login situation. And
non-interactive shells don't see all the stuff in the 'if' section.

Please correct if wrong :)

--
Hal Burgiss


Hal, this is my thinking....and the reason I tried to put my aliases in ~/.bashrc. I presume in KDE, when I click the terminal button and get a new shell with a prompt, this is a non-login interactive shell. As I understand it, ~/.bashrc gets called for these but /etc/profile and ~/.bash_profile do not (please correct if wrong). So, it seems if I want the aliases to always work, I need to put them in the ~/.bashrc file so they will get sourced when I open a new terminal window. I will try your trick, but I still do not understand why when I put the alias and set the prompt in the ~/.bashrc file it does not work, especially since a few here have posted that it works fine for them.... ???

Helllppp....

And thanks.
Jim




--
http://www-personal.umich.edu/~jimkk/Index.html

Reply via email to