.bashrc/.profile is not loaded on new tmux session (or window) -- why?

John Smith picture John Smith · Mar 11, 2012 · Viewed 34.8k times · Source

When tmux starts or opens a new window, it does not load my .profile or .bashrc. I end up typing . ~/.bashrc every time. Is there a way to make this happen automatically?

Answer

paxdiablo picture paxdiablo · Mar 11, 2012

Yes, at the end of your .bash_profile, put the line:

. ~/.bashrc

This automatically sources the rc file under those circumstances where it would normally only process the profile.

The rules as to when bash runs certain files are complicated, and depend on the type of shell being started (login/non-login, interactive or not, and so forth), along with command line arguments and environment variables.

You can see them in the man bash output, just look for INVOCATION - you'll probably need some time to digest and decode it though :-)