I ran gnome-terminal --working-directory=$DIR but it opens in a new window, not tab.

Things I've tried:


Running RHEL5 with zsh


2 Answers 2


Verbatim copy of the only way to do this that I've ever seen, using xdotool, xprop, & wmctrl.

Source: Open a new tab in gnome-terminal using command line

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.

  • What about using xdotool key ctrl+shift+t only?
    – Pandya
    Commented Jan 4, 2016 at 11:16
  • @Pandya - you need to get the window's ID so that you can force xdotool to focus on it prior. Without these there are various situations where the above won't work otherwise.
    – slm
    Commented Jan 4, 2016 at 13:21

If you want to open a new tab into an alredy-existing gnome-terminal window try ctrl-shift-t

  • I know that option, but I am intentionally asking for shell scripting
    – user49888
    Commented Sep 18, 2014 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .