dan
dan

Reputation: 45632

How do you get a custom Gnu screen config to load .bash_profile and .bash_aliases?

I have a custom screen configuration myscreenconfig and a .screenrc. myscreenconfig looks like this:

source .screenrc
screen 0 bash
title 'notes' 
screen 1 bash
title 'bash' 
[etc.]

.screenrc has these lines at the top:

altscreen on
shell -${SHELL}

My .bash_profile file sets a lot of things and then calls source $HOME/.bash_aliases.

If I start screen without any arguments, my .bash_profile gets loaded and .bash_aliases gets loaded. But if I start screen via screen -c myscreenconfig, only .bash_profile gets loaded, and not .bash_aliases. Why? How can I fix this?

Upvotes: 3

Views: 2187

Answers (4)

Victor Sanchez
Victor Sanchez

Reputation: 640

I'm use this in my .bashrc

if [ "$TERM" = "screen" ]; then
        if [ -f ~/.bash_profile ]; then
                . ~/.bash_profile
        fi
fi

Upvotes: 0

n1ghtm4n4g3r
n1ghtm4n4g3r

Reputation: 6623

I had the same problem on one of the machines I use. After reading the suggestion above about linking the two bash resource files, I realized that the following section had been put in comment in the .bash_profile file on this particular machine:

# Get the aliases and functions
# if [ -f ~/.bashrc ]; then
#    . ~/.bashrc
# fi

After removing the comment signs (#) from before the if block lines, settings in .bashrc became available in screen sessions as well.

Upvotes: 2

CamelBlues
CamelBlues

Reputation: 3764

What worked for me was making a symbolic link between wherever I had my bash settings and .bashrc (which I did not have):

ln -s ~/.bash_profile ~/.bashrc

Upvotes: 3

user562374
user562374

Reputation: 3897

Because you are not using login shells in myscreenconfig. Use (IIRC) screen 0 -bash, or try combinations with deflogin on.

Upvotes: 0

Related Questions