I have ~/.bash_profile which I would like to be invoked every single time a new GNU screen is created so that all my aliases work in GNU screen as they work in terminal.

At this time this is what my ~/.screenrc looks like.

hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
  • 1
    I solved this problem by moving all the contents of ~/.bash_profile to ~/.bashrc. Apparently screen invokes ~/.bashrc before each window.
    – Nadal
    May 6, 2010 at 21:22

6 Answers 6


shell -$SHELL

Add the above line to your ~/.screenrc, this will make screen start-up using a login shell which will load your ~/.bash_profile.

  • This stops screen starting in the current directory. How do I make screen start in the current directory? Feb 9, 2017 at 11:35

Some Mac applications rely on .bash_profile and some on .bashrc. I have not figured out any particular rule for knowning which one is getting loaded but for consistency this is my .bash_profile:

if [ -f ~/.bashrc ]; then
. ~/.bashrc

I solved this problem by moving all the contents of ~/.bash_profile to ~/.bashrc. Apparently screen invokes ~/.bashrc before each window. – Nadal May 6 '10 at 21:22

This comment is the right answer.


Debian and Ubuntu (at least), in their standard configuration, have a /etc/profile.d/ directory from which any containing file ending by .sh are sourced by /etc/profile.

This is very practical for adding configurations, but makes users thinking this is the proper place for dropping their new settings, whereas this is not always true.

I don't understand why they didn't do the same for /etc/bash.bashrc, I hope they will do it in some future, but in the meantime, I did it myself:

  1. Create a new directory at /etc/bash.bashrc.d/

  2. Similarly to what exists in /etc/profile, add the following lines at the end of /etc/bash.bashrc:

    if test -d /etc/bash.bashrc.d/; then
        for bashrc in /etc/bash.bashrc.d/*.sh; do
            test -r "$bashrc" && . "$bashrc"
        unset bashrc
  3. Starting from now, drop files needed for non-interactive shells in /etc/bash.bashrc.d/ rather than in /etc/profile.d/.

That way, the only change needed to existing files is at the end of /etc/bash.bashrc.

I think this is the main reasons for users complaining about their profile not loaded, but actually their profile may not NEED to be loaded.

Maybe you could read this about this subject.


The problem is a little vague; shell startup files are run by screen upon creation of windows, that yours aren't feels like something is misconfigured in your .bashrc or .bash_profile. I haven't run into this using screen on OS X.

Have you tried iTerm instead of screen? I use it exclusively on my Mac and then use screen on the servers I admin.


I added a .bashrc file that just contains:

[[ -s ~/.bash_profile ]] && source ~/.bash_profile

This way any program such as GNU screen that looks for .bashrc will find it, and source my .bash_profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.