views:

321

answers:

2

Hi All,

Is there a way to launch a gnome-terminal from the command line (i.e., using the /usr/bin/gnome-terminal command) and have the new terminal inherit the environment variables and other set variables of terminal from which the command was run? The scenario is thus:

  1. Open a terminal
  2. Set some variables
  3. Set some environment variables
  4. Launch an executable that needs the variables and the environment variables of the current terminal in a new terminal

Thoughts?

+1  A: 

You need to use export against the variables in the other shell if you want child processes to inherit them.

Ignacio Vazquez-Abrams
This is along the right lines, except setenv has to be used rather than export because it is a c shell. However, I'm still having a problem. If I'm in a tsch and set an environment variable and then switch to csh, it works fine. However, if I'm in csh, set an environment variable, and switch to tcsh (in a new gnome-terminal), the environment variables are not propagated into the tsch. Any thoughts?
Adam
Unfortunately C-shells are not really my strength; I do much better with `sh` derivatives.
Ignacio Vazquez-Abrams
A: 

This turned out to be a gnome-terminal issue. When launching the gnome-terminal, specifying the --disable-factory option provides the following directive:

"Do not register with the activation name server, and do not reuse an already running GNOME terminal process" (gnome-terminal man page)

Specifying this option was required in order to inherit the environment of the previous shell.

Adam