I'm on OSX Mavericks and having trouble with gnuscreen both sourcing bash and starting in the working directory at the same time. Solutions that I've seen for the former clash with the latter.
Asked
Active
Viewed 60 times
0
-
1What the heck do you mean by "sourcing bash"? It *is* bash, and it's always going to source your `~/.bashrc`. Do you mean you want it to run your `~/.bash_profile` as well? – Mark Reed Oct 19 '14 at 00:48
-
Yes, that is what I want it to do. I have env vars there that I'd like to retrieve. – user592419 Oct 19 '14 at 00:56
-
`cd working_dir; screen bash -l` will move to `working_dir` and start a login shell of `bash` inside `screen`. Because it is a login shell, it will source `~/.bash_profile`. – John1024 Oct 19 '14 at 01:34
-
That last command does the trick, but it also means that I can't just type in `screen`, but have to do `screen bash -l`. I suppose I can alias it, but how can I make it so that screen always does that? – user592419 Oct 19 '14 at 02:01
-
@user592419 I solve the problem differently. My `~/.bashrc` tests to see if my shell variables are defined. If they aren't, it defines them. (These definitions are shared with `~/.bash_profile`.) – John1024 Oct 19 '14 at 05:21
-
Ok, so that seems to work where I put all of my env vars in ~/.bashrc, don't use ~/.bash_profile, and get rid of `shell -bash` in ~/.screenrc. If I even have bash_profile though, then osx seems to take that as precedent and doesn't load the vars. Thanks John. – user592419 Oct 19 '14 at 20:18
1 Answers
0
Put something like this in your .bash_profile
:
export PROFILE_RUN=1
And then put this in your .bashrc
:
if [ -z "$PROFILE_RUN" ]; then
. ~/.bash_profile
fi

Mark Reed
- 91,912
- 16
- 138
- 175
-
If it doesn't work, then something else is going on in your case. Please provide more details of your configuration if you want to explore this path. – Mark Reed Oct 21 '14 at 14:31