I use screen on a daily basis for my terminal needs and I'm quite happy with it. Recently, though, I made some updates to my bash configuration files and I noticed that I was setting various PATH
elements (PATH
, MANPATH
, INFOPATH
, etc) in 2 places. I modified the files to be what they should be and now all of my environment variables get set once in .bash_profile
. Herein lies my problem.
Apparently, the reason I was setting them in two places was because of screen. screen appears to only execute .bashrc
and does not appear to inherit my PATH
or any other environment variables correctly from my original bash shell. Because it only executes .bashrc
and I now set my variables in .bash_profile
only, I get an incomplete PATH
.
My question, then, is how to get my environment variables into screen without the duplication. Reading through the Bash
docs seems to indicate that it could be the kind of shell that screen uses to log in, i.e. a non-login interactive shell but I couldn't figure out how to force screen to use a particular kind of shell, only the shell to use via -s /bin/bash
.
You can peruse my config files at my GitHub page. This is the commit commit that broke screen.
EDIT: I'm using Screen version 4.00.03 (FAU) 23-Oct-06
and I tend to invoke it by screen -h 50000
EDIT: I've now been able to test this on Cygwin (CYGWIN_NT-5.1 1.7.1(0.218/5/3) i686
, Screen version 4.00.03 (FAU) 23-Oct-06
) and it exhibits different behavior than on my Mac.
The specific behavior that I've now discovered is that in Cygwin the changes that I make to PATH
in .bash_profile are duplicated upon entering screen and then successive creation of screen windows do not duplicate the path but do re-source .bash_profile.
To illustrate the behavior I'm talking about:
Output from a fresh terminal:
...
PATH: /home/tvishe01/bin/emacs/bin:/home/tvishe01/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/ATI Technologies/ATI.ACE/Core-Static:/groovy-1.6.1/bin:/usr/lib/lapack
MANPATH: /home/tvishe01/share/man:/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man
Aliases:
alias ..='cd ..'
alias ...='cd ../..'
...
[~]$
Output from the first invocation of screen:
[~]$ screen -h 50000 -s -/bin/bash
...
PATH: /home/tvishe01/bin/emacs/bin:/home/tvishe01/bin:/usr/local/bin:/usr/bin:/bin:/home/tvishe01/bin/emacs/bin:/home/tvishe01/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/ATI Technologies/ATI.ACE/Core-Static:/groovy-1.6.1/bin:/usr/lib/lapack
MANPATH: /home/tvishe01/share/man:/usr/local/man:/usr/share/man:/usr/man:/home/tvishe01/share/man:/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man:/usr/ssl/man
Aliases:
alias ..='cd ..'
alias ...='cd ../..'
...
[~]$
Subsequent calls to C-a c
:
...
PATH: /home/tvishe01/bin/emacs/bin:/home/tvishe01/bin:/usr/local/bin:/usr/bin:/bin:/home/tvishe01/bin/emacs/bin:/home/tvishe01/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/ATI Technologies/ATI.ACE/Core-Static:/groovy-1.6.1/bin:/usr/lib/lapack
MANPATH: /home/tvishe01/share/man:/usr/local/man:/usr/share/man:/usr/man:/home/tvishe01/share/man:/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man:/usr/ssl/man
Aliases:
alias ..='cd ..'
alias ...='cd ../..'
...
[~]$
You can see