Search code examples
bashgnome-terminal

Opening multiple terminals with gnome-terminal


I would like to run a .sh file that launches several terminals in specific folders, each of these executing a specific command.

How would I do this using gnome-terminal?

I checked this page "http://manpages.ubuntu.com/manpages/zesty/man1/gnome-terminal.1.html" but I'm still stuck.


Solution

  • You can have multiple lines like this in your script:

    #!/bin/bash
    
    gnome-terminal --working-directory=/path/to/dir1 --command './some-command1' &
    gnome-terminal --working-directory=/path/to/dir2 --command './some-command2' &
    

    very similar to this answer.

    Note the use of & to run the terminal in background. Other options should be self-explanatory.