Use RoxTerm instead –
'roxterm --tab' opens a new tab in an existing terminal window, with no hack described here.
GNOME terminal has great support for tabbed terminal sessions. You can simply open a new tab by pressing CTRL+SHIFT+T and it’s very convenient.
However, it seems like there’s no straightforward way to ask
gnome-terminal command to reuse an existing window and add a new tab there. I tried various options like
--tab, but they didn’t work as I expected. I just want to keep only one terminal window in my desktop, but it looks like there’s no command line option that does the job.
So, I wrote a shell script that adds a new tab to an existing GNOME terminal window when there is already a running instance. It also launches a new terminal window if necessary:
#!/bin/bash # Path: /usr/local/bin/gnome-terminal if [ "x$*" != "x" ]; then /usr/bin/gnome-terminal "$@" else pgrep -u "$USER" gnome-terminal | grep -qv "$$" if [ "$?" == "0" ]; then WID=`xdotool search --class "gnome-terminal" | head -1` xdotool windowfocus $WID xdotool key ctrl+shift+t wmctrl -i -a $WID else /usr/bin/gnome-terminal fi fi
This script looks for an existing gnome-terminal window, sends CTRL+SHIFT+T key event there, and raises the terminal window. Please note that xdotool and wmctrl are required to run the script. They should be available in most Linux distributions.
It’s just a band-aid solution – I hope I can get rid of this script from my system when the next release of GNOME terminal is out.