login shell .profile
interactive non-login shell .bashrc
run by the remote shell daemon .bashrc
I wasn't sure exactly what counted as a "login" shell so I got each of my .profile and .bashrc printing into a logfile. These are my observations on OS X: log into OS X user account (nothing)
new terminal .profile
run "bash" from that terminal .bashrc
run a shell script (nothing)
ssh hostname .profile
ssh hostname somecommand .bashrc
The behaviour of ssh seems (to me, at least) to contradict the bash man page. Anyway this was all so complicated that I'll never remember it, so what I ended up doing was:* .profile does nothing other than source .bashrc
* In .bashrc anything that should be specific to interactive shells goes inside:
if [ -n "${-//[^i]}" ]; then
...
fi