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?

5 Answers 5


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.

  • Ah thanks! In addition, is there a way to easily let myself know that this current window is inside gnu screen?
    – xjq233p_1
    Jul 24, 2011 at 22:46
  • the hardstatus option in the .screenrc file can be used to help with making sure that you can identify that you are in screen (along with some other nifty settings too I understand). The screen man page should have the details on how to configure it (don't know those off the top of my head). Jul 24, 2011 at 22:51

Sourcing .bash_profile is actually something different that the Mac terminal app does that most terminal apps don't do. Screen does read ~/.bashrc however, each time you spawn a new shell.

If you rename your ~/.bash_profile to ~/.bashrc (with no underscore between bash and rc, as in your question), then it will be sourced.

My preferred strategy however is to put all of my settings in the bashrc, and then source it from bash_profile like this:

[ -f .bashrc ] && . .bashrc

This command will fix you:

$echo "shell bash" >> ~/.screenrc

you can find a lot of options on configuring gnu-screen in this link


You don't need to change any config file, if you write all your settings to .bash_profile, like you normally do to set up your terminal, and create a link named .bashrc pointing to your .bash_profile for the screen sessions via:

$ ln -s ~/.bash_profile ~/.bashrc

Any changes made to one of the files are stored in .bash_profile but also accessible by .bashrc.

The only drawback is that you cannot add settings to only one of the config files.

  • Can you expand upon this answer a bit? You haven't really explained how this would solve the problem.
    – bwDraco
    Dec 7, 2014 at 2:42

Linux login shells source non-login ones by adding the following line in case of user files:

[[ -f ~/.bashrc ]] && . ~/.bashrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .