I want to be able to open a new terminal tab in the current terminal window and run a command in the new terminal tab from a script. Note that I don't want to open an entirely new terminal window, just a new tab.

Running the following opens a new tab as desired, but the echo command gets run in the terminal that executed the script as opposed to getting run in the new tab

xdotool key ctrl+shift+t
echo 'hi'

If there's anyway to do this without using Tmux I'd greatly appreciate it!


Newest gnome-terminal versions support

gnome-terminal --tab -e [command ...]
  • Yes I'm aware of this but this isn't what I was looking for. This opens a new terminal window as opposed to a new tab in the current terminal
    – J-Win
    Jul 6 '19 at 14:33
  • That's what it does in recent versions, e.g. in Ubuntu 19.04.
    – egmont
    Jul 7 '19 at 7:43
  • Ah I see. I'm still on Ubuntu 16.04
    – J-Win
    Jul 7 '19 at 15:45

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.