Linux – Opening new gnome-terminal (v3.28+) with multiple tabs and different commands

gnomegnome-terminallinux

It seems the behavior of gnome-terminal has changed between the version shipped with Ubuntu 14 (v3.6?) and Ubuntu 18 (v3.28).

I have a script that opens a new gnome-terminal with a bunch of tabs setup to different directories for my development, and currently the first tab runs a script. The command to open the gnome-terminal with tabs looks something like this:

gnome-terminal \
   --tab --command="myscript.sh" \
   --tab --working-directory="<some dir 1>" \
   --tab --working-directory="<some dir 2>" \
   ...

This works perfectly as desired in the gnome-terminal version that shipped with Ubuntu 14 (v3.6?).

But in the gnome-terminal version that ships with Ubuntu 18 (v3.28) several things have changed:

  1. Unless I add the --window option, the tabs open in the current gnome-terminal, not a new one. Unfortunately adding the --window option opens an initial blank tab. Is it possible to open a new window with only the tabs that I specify?
  2. I now get the following notice (though it functions as before):

    # Option “--command” is deprecated and might be removed in a later version of gnome-terminal.
    # Use “-- ” to terminate the options and put the command line to execute after it.
    

    Changing my script per this guidance changes the behavior such that the command is issued to all tabs, whereas before I could apply a unique command to each tab. Does this mean the ability to run a separate command per tab has been deprecated, or am I missing something?

I appreciate suggestions on how to change my script to support the old behavior in the newer gnome-terminal.

Best Answer

I had the same issue, and after a huge number of attempts I found the following solution

gnome-terminal -- bash -c "myCommand -some-args; bash" &
gnome-terminal -- bash -c "myOtherCommand -some-args; bash" &
Related Question