How to tell GNU screen to run .bash_profile in each new window?

When I open a new window in GNU screen, it runs .bashrc but not .bash_profile. In my setup, this results in some environment variables not being set up correctly in that window.

How can I tell GNU screen to always run .bash_profile instead of .bashrc on opening a new window? (Please don't tell me to just call .bash_profile from my .bashrc :)


Solution 1:

You want to start bash (or whatever shell) as a login shell. You do this with

shell -$SHELL

in your ~/.screenrc. The magic is the - before the shell. See man screenrc for details. (Well, not many more details, because that's pretty much it.)

Solution 2:

You would either need to source ~/.bash_profile from ~/.bashrc or put the things you need directly into ~/.bashrc or put the things in common in a third file and source it from both your ~/.bashrc and ~/.bash_profile.