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

Things I've tried:


Running RHEL5 with zsh


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
    Jan 4 '16 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
    Jan 4 '16 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
    Sep 18 '14 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.