Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tend to use the terminal a lot,

So I wondering if there is a way I can make Ctrl+Alt+T focus the existing terminal if there is one, otherwise create a new terminal?

share|improve this question
up vote 18 down vote accepted

Create a small script which will raise the GNOME Terminal:

echo 'xdotool windowactivate $(xdotool search --onlyvisible --class gnome-terminal)'> ~/ && chmod +x ~/

or if you want to check if Terminal is already running, use:

echo -e $'if ps aux | grep "[g]nome-terminal" > /dev/null\n then xdotool windowactivate $(xdotool search --onlyvisible --class gnome-terminal)\n else gnome-terminal &\nfi' > ~/ && chmod +x ~/

This will create the script ~/ with this content:

if ps aux | grep "[g]nome-terminal" > /dev/null                                                                                                                                                                                
 then xdotool windowactivate $(xdotool search --onlyvisible --class gnome-terminal)                                                                                                                                            
 else gnome-terminal&                                                                                                                                                                                                          

Open the preferences to set up a custom keyboard shortcut and set the command to /home/$USER/, but make sure to change $USER to your actual username.

If you only want to raise the terminal on a specific screen or desktop, see xdotool search --help for more information on how to do this.

There are also various other methods which work better with other window managers.

share|improve this answer

why don't you try tilda or guake, both available in ubuntu repositories. Although they don't specifically do what you're after, I'm sure they are that thing that you were looking for but did not know it existed. ;)

EDIT: ok, I was a bit vague, more information follows:

from wikipedia:

Tilda is a GTK+ terminal emulator. Its design was inspired from consoles in computer games such as Quake which slide down from the top of the screen when a key is pressed, typically the tilde, and slide back up when the key is pressed again.

Running Tilda can be faster than launching a new terminal with a keyboard shortcut because the program is already loaded into memory; it can be useful to people who frequently find themselves opening and closing terminals for odd tasks.

guake is really the same thing, the only difference I noticed is that I couldn't make it open http links by ctrl+click which I found annoying

share|improve this answer

My version (=

Script to run/raise any app:

xdotool search --class $1 | while read line
echo "$line"
if [ `xdotool windowactivate $line 2> /dev/stdout | grep -c fail` -eq 0 ]
kill $PID
$1 & disown


sh ~/ chromium
share|improve this answer

Your Answer


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.