Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Please clarify your question with specifics. What type of script you are executing and on which shell (terminal) you want to run the scripts? Give us a usecase, like my shell script is this and I want to run it in csh or zsh or bash –  Web-E Aug 16 '12 at 5:55
add comment

3 Answers 3

up vote 7 down vote accepted

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.

share|improve this answer
    
Just to know there isn't a system variable or something like that that calls the default terminal on the system? –  Topo Aug 16 '12 at 17:29
4  
echo $TERM tells you the name, whereas $TERM launches it. Most of the time it's xterm :) –  nitstorm Aug 16 '12 at 18:03
add comment

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.

share|improve this answer
add comment

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.).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.