Single instance of the GNOME Terminal?

Solution 1:

I wrote a simple shell script using wmctrl to give the Terminal focus. It does exactly what I want.

First, install wmctrl sudo apt-get install wmctrl.

Next, fire up a text-editor, copy the following lines.

#!/bin/sh
SERVICE='gnome-terminal'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
  wmctrl -xa $SERVICE
else
  $SERVICE
fi

Save the file somewhere where you usually keep your shell scripts. In my case I did: ~/bin/single_instance.sh

cd to the directory (cd ~/bin) and make the file executable chmod +x single_instance.sh

Now, open up Main Menu select Accessories » Terminal press properties and replace command with the script: ~/bin/single_instance.sh

Open up System Settings » Keyboard » Shortcuts. Disable Launch Terminal shortcut by giving it a backspace. Make a custom shortcut. Again fill in the path and name to the script and give it the key combination ctrl + alt + t.

You’re done, single instance terminal...

Solution 2:

Add --tab to the launcher command. Then you end up with only one app. open.

~$ gnome-terminal --help-all
:
--tab       Open a new tab in the last-opened window with the default profile