How to open a terminal from the terminal

I'm on ubuntu 12.04 and I use gnome terminal as my default terminal. I need to open another terminal from the command line. I know I can do this with gnome-terminal but I want to run a command that always opens the default terminal so that my script can run on other distros, even the ones not using gnome.

EDIT: I want a bash script that opens the terminal.


Solution 1:

xterm is available by default on almost all Linux distributions if I remember correctly.

So you could run a command in it, depending on the shell that the script's written in with something like this, (the example is for a bash shell script)

xterm -e "sh script.sh"

It'll spawn a new shell window and execute your script.

Solution 2:

According to the answer to this question How can I set default terminal used in Unity? I would script it as follows:

 eval "$(gsettings get org.gnome.desktop.default-applications.terminal exec)"

If you would like to start a program inside the terminal, there is also the property 'exec-arg' which specifies the argument needed to execute something in the terminal by that specific terminal. For example when you want to execute a 'tail -f /var/log/messages':

CMD='tail -f /var/log/messages'
eval "$(gsettings get org.gnome.desktop.default-applications.terminal exec) $(gsettings get org.gnome.desktop.default-applications.terminal exec exec-arg) \$CMD"

The 'eval' is used because 'gsettings' returns the command and the argument in single-quotes. This would then be a generic solution for all desktops running GNOME/Unity.

Solution 3:

You might want to use either this key combination CTRL + SHIFT + T which opens another tab in the same terminal window, or you might want to use this one: CTRL + ALT + T which opens another terminal window (without closing the one you currently use.).