1

I initially thought this would be a very simple thing to do:

write a script which opens several fresh gnome-terminal windows, runs a command in each of them, and leaves them open. The automated equivalent of doing CTRL+ALT+T several time, and running a single command in each of the opened windows.

However, looking at many answers here (for example), it seems like I am missing a simple answer or it does not exist.

Using the recommended

gnome-terminal
and its variations, such as
gnome-terminal --tab --title="test" --command="bash -c 'cd /etc; ls; $SHELL'"

A new terminal window does open up, but it is a subshell, and .bashrc gets executed a second time. Thus some exports, and other commands fail or create doubled variables. (e.g. having export PROMPT_COMMAND="history -a; $PROMPT_COMMAND" in .bashrc, the new terminal now has "history -a; history -a;" in $PROMPT_COMMAND).

Additionally, the command gnome-terminal seems to also inherit the working directory, and some (but not all) variables from the shell that launched it.

So is there a way to launch a fresh (i.e, in exactly the same state as if I pressed CTRL+ALT+T) gnome-terminal instance from the command line?

( man gnome-terminal and gnome-terminal --help-all do not mention such an option. )

Dugas
  • 113

0 Answers0