In bash, we have the inherent separation of .bash_profile
and .bashrc
, with the former running for login shells and the other for all shells. Now, I understand it's common to start an interactive non-login shell from a non-shell process, and for this reason I find myself running quite a bit of initialization stuff in my .bashrc
. The thing is, one also often invokes the shell from within an interactive shell session, or within shell scripts; and I'm not at all sure none of them runs .bashrc
. So, I think I would like to somehow constrain some of the stuff I do in my .bashrc
to only happen in "top-level" interactive shells in some sense.
Is there some convention on how this is done? Or perhaps, is it too much of a hassle compared to the benefit?
.bashrc
. They don't really need to, since they're already copies of the main shell which already did run whatever initialization files it did in the mode it was in. That should be easy to check by putting something likeecho this is bashrc
in.bashrc
and running e.g.(echo hi)
or: $(echo hi)
.bash
process...(for the record, when run assh
,--norc
is implied...)