.bashrc / .profile does not load into a new tmux session (or window) - why?

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

+76
tmux
Mar 11 '12 at 3:19
source share
5 answers

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

 . ~/.bashrc 

This automatically creates the rc file in cases where it usually processes only the profile.

The rules regarding when bash run certain files are complex and depend on the type of startup shell (login / non-login, interactive or not), etc.), as well as command line arguments and environment variables.

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

+122
Mar 11 2018-12-12T00:
source share

Running bash obviously worked for me by adding this line to the ~ / .tmux.conf file:

 set-option -g default-command "exec /bin/bash" 
+7
Nov 15 '17 at 21:08
source share

From this thread:

It seems that using .bash_profile will work.

+1
Mar 11 2018-12-12T00:
source share

I had the same problem and the solutions have not worked for me yet. The solution that worked for me can be found here .

In short, tmux windows / sessions uses a login shell that looks for the ~/.profile file among other files when it starts.

I wanted zsh to start with every new tmux window so I exec zsh in exec zsh my ~/.profile .

0
Jul 24 '18 at
source share

The solution that worked for me is the following:

  • Create a .bash_profile file if you don’t have it in ~
  • At the end of .bash_profile put source ~/.bashrc or source ~/.profile
  • Restart tmux.

Now the problem should be fixed.

0
Dec 05 '18 at 8:05
source share



All Articles