I'm trying to write a .screenrc file that I can use to set up for a developing on a particular project - It will start a few screens, cd to the right places, open up the right files in an editor, and set some environment variables needed for testing.
I can't get the environment setup to work.. I've tried putting this in `~/.screenrc
:
setenv PATH ~/src/my_proj/bin/:$PATH
This doesn't work, and I think the problem is that after screen
sets PATH
, the regular shell initialization scripts kick in and change it on me.
I don't want to disable the regular shell init scripts. Is there any way to make screen setenv
after the shell is initialized? Or alternatively, can screen set a variable to read-only?
Note: To specify operating-system environment variables in an edit box, use the following syntax: $(VariableName) . The $(Config) variable resolves to the specific configuration that is set in the Target field on the specific Project Options page where $(Config) is specified, for example Delphi Compiler.
To access this page, select a project node in Solution Explorer, select Project > Properties from the Visual Studio menu, and then select the Environment Variables tab. Specifies the name of an environment variable that will be used when the project is built or when the project is run from Visual Studio.
To print the value of a particular variable, use the command " echo $varname ". To set an environment variable, use the command " export varname=value ", which sets the variable and exports it to the global environment (available to other processes). Enclosed the value with double quotes if it contains spaces.
There's no way that screen
can change the environment variables of a shell process once that process has launched, nor is there any way to make an environment variable read-only (values are stored in each process's memory, and each process has full access to them).
(Well, there might be some ugly system-specific way to do it, but it's the kind of thing Unix-like systems are designed to keep you from doing.)
You'll need to modify your shell's initialization script so that it retains the existing value of $PATH
, possibly adding to it, rather than setting it to some new value ignoring its existing value.
If you want to do this conditionally, you can test for the existence of $STY
, which is set only if the shell (or any other process) is running under screen
.
Also, screen
's setenv
command doesn't seem to recognize the ~
character. I tried adding a similar setenv
to a temporary screenrc
, and $PATH
contained a literal ~
character. bash
seems to recognize the ~
syntax in $PATH
, but other shells do not. Replace the ~
by $HOME
, which screen
does recognize.
for me the line
setenv PATH /home/someuser/bin:$PATH
in the screenrc file did the trick.
I think the expansion of '~' to '/home/someuser' is bash specific and will not work within the screenrc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With