GNOME Terminal
offers no generic command line solution to open a new tab in an already existing window.
(Why? Because it may have multiple windows open, and it wouldn't know in which one to open the new tab. You might say you only have one window, but if such a feature was implemented, the software would need to be consistent and need to do something reasonable when it had multiple windows, which it couldn't really do.)
Hacks, such as simulating the user pressing a key, exist as per an already filed answer, but work only under X.Org, not under Wayland.
Beginning with forthcoming version 3.28, the command gnome-terminal --tab
will open a new tab in the GNOME Terminal window where this command is executed from, if this command is executed from within GNOME Terminal.
(How does it know in which window to open the new tab in this case? It knows by setting a certain environment variable upfront to a different value in each of the terminals it opens. That environment variable lets it locate the desired window.)
So for your particular case, you could do:
gnome-terminal --tab -- bash -c 'cd /; exec bash'
This way you get a running shell in the new tab once the cd /
is completed. If you just did gnome-terminal --tab -- some command
, then the tab will close immediately after some command
exits. By using bash -c 'some command; exec bash'
instead, the tab will have a running bash
process once some command
completes.