When an interactive shell that is not a login shell is started,
reads and executes commands from
~/.bashrc, if that file exists.
So if your shell is a login shell,
~/.bashrc is not read.
I would put additions to
~/.bash_profile instead, and/or possibly source
~/.bashrc from there.
Some shells makes a distinction between two or three types of shell initialization files:
- A profile file that is read by login shells.
- A file that is read by interactive shells.
- And possibly, a file that is read by non-interactive shells, i.e. scripts.
- Whatever file
$BASH_ENV points to.
The point of separating the profile startup script from the script read by interactive shells is to let you do (potentially heavy) set-up tasks for all your future shell sessions once and for all. This usually involves setting the
PATH at the minimum, but also any other exported variables (i.e. environment variables).
The interactive shell initialization script (
~/.bashrc in the case of
bash) then only needs to do thing specifically needed for interactive shells. This includes setting shell variables like
PS1 that shouldn't be exported, and defining aliases and functions etc. You should also set up environment variables that need to be set for this session and any started process from this session, such as
GPG_TTY="$(tty)") if you're using GnuPG.
I tend to
source $HOME/.bashrc from my
~/.bash_profile after setting my
PATH and adjusting my
umask the way I want them, and let
~/.bashrc set up history file variables, the
EDITOR and a few aliases and functions and whatnot. (That's half a lie; I actually
ksh93 shell from my profile if I can find it, but if I can't, I continue with
bash). I also renice my shell in the interactive shell initialization file (with
renice -n 4 $$), because I often work on a shared machine with loads of other people that needs the CPU more than I do (but that's just me).
ksh93 shell uses
~.kshrc (or whatever
$ENV points to)
ksh93 is a bit saner than
bash in that it knows there is such a thing as an interactive login shell, so it reads
$ENV (if it is set) for those shell sessions too, after reading
pdksh shell also reads
~/.kshrc for non-interactive shells, which annoys me (and breaks a few important scripts that I use), so I have
case $- in
*) return ;;
at the top of my