Open a new tab in gnome-terminal using command line

Vikrant Chaudhary picture Vikrant Chaudhary · Jul 27, 2009 · Viewed 143.1k times · Source

I'm using Ubuntu 9.04 x64 and when I write:

gnome-terminal --tab

At the terminal, I expect it to open a new tab in the same terminal window. But it opens a new window instead.

I found out that its intention is to open a new tab in a new window, i.e., if I write:

gnome-terminal --tab --tab

It will open a new window with two tabs.

So, the question is, how can I open a new tab in the current window using a command in gnome-terminal?

Answer

utkarsh dubey picture utkarsh dubey · Feb 3, 2010
#!/bin/sh

WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
xdotool windowfocus $WID
xdotool key ctrl+shift+t
wmctrl -i -a $WID

This will auto determine the corresponding terminal and opens the tab accordingly.