Place Ghantoos

screen(1), /etc/profile, ~/.profile, /etc/bash.bashrc and ~/.bashrc


For a while, I have been having problems with screen(1) on some of my machines. I am not the “colors in my terminal” type of guy. But unfortunately, when you get used to having “some” colors out there, it is disturbing to lose them when going inside a screen.

The problem was that screen(1) did not source neither /etc/profile nor ~/.profile when it spawned a new shell; only /etc/bash.bashrc and ~/.bashrc were sourced.
As I don’t like having my preferences included in bash specific files, they were all added in *profile (specifically in /etc/profile.d/).

In order to find the source of the problem, I just added “echo ” in the different files (the ones in the title on this post ;) ). And launched screen to see which files were actually sourced.

The solution was quite simple. Let screen(1) spawn its shells as your login shell using the $SHELL environment variable. Add the following to /etc/screenrc or ~/.screenrc:

# make the shell in every window as your login shell
shell -$SHELL

À bon entendeur, salut!

Ignace M


Leave a Reply