If bash is my shell, what should I put in ~/.bash_profile
and what should I put in ~/.bashrc
?
My understanding is that ~/.bash_profile
is read on login, and ~/.bashrc
is read for each new interactive non-login shell. I can set ~/.bash_profile
to read ~/.bashrc
if I want.
But since I can't actually think of anything that I don't want to always be set to some initial value, and since every Unix process (not only the shell) inherits the environment variables of its parent process, why wouldn't I just put everything into ~/.bash_profile
and just forget about ~/.bashrc
? What is the rationale for setting things again and again to the same value every time ~/.bashrc
is read, when they could just be set once initially in ~/.bash_profile
?
Or maybe what I'm really asking is what logically goes into each of ~/.bash_profile
and ~/.bashrc
, irrespective of my own requirements.
(I fully admit ignorance, and I'd also gladly be corrected on the above if my understanding is incorrect.)
.bashrc
to me. The answer over there says of.bashrc
, "aliases, functions, etc [...] are per shell session items that are not inherited from environment." Well, aren't they inherited from the environment? – osullic Jul 13 '20 at 20:03PS1
that no other process would care about. – chepner Jul 14 '20 at 19:44