Mac Gnu-Screen doesn’t load default .bash_profile

gnu-screenmac

I have a bunch of custom settings in my bash_profile. when I use gnu-screen, I realized that my screens do not execute source /Users/disappearedng/.bash_profile. I try to put source /Users/disappearedng/.bash_profile in my .screenrc file but then it complains that alias is not a command… (I guess that screenrc needs screenrc specific command).

I have tried changing my .bash_profile to .profile or .bash_rc. None of that work.

Any help?

Best Answer

The .bash_profile file (and .profile file as well) is loaded for login shells, non-login shells use .bashrc (no _ symbol). There is a line in the .screenrc file that tells screen what shell to spawn when starting a screen window (when not launching a specific program as the window application). In my .screenrc file, this is as such (including comments as well):

# shell:  Default process started in screen's windows.
# Makes it possible to use a different shell inside screen
# than is set as the default login shell.
# If begins with a '-' character, the shell will be started as a login shell.
  shell -$SHELL

Check your .screenrc file and verify that the shell line has the dash in front of it. By having that dash symbol and forcing a login shell, you'll get your .bash_profile sourced. The $SHELL variable in my .screenrc is using the shell value as provided by the shell that launches screen (generally for me it's bash).

In case you're wondering, the biggest difference that I've been able to discover between login versus non-login shells is that a non-login shell is normally what's invoked for executing scripts.

Related Question