Using mate-terminal to open tabs, run commands, and remain interactive

Hey there, maybe you can help? I've been defeated many times trying to do this.

I want to run one script (e.g. happycoding.sh) that:

  • opens my dev env in multiple tabs, preferrably zsh
  • each tab runs a command line to start database, api, www tests, etc.
  • when that command terminates (crashes, exits, ctrl-c 'd, etc) , zsh continues in interactive mode

Long ago, I was able to do it in gnome--terminal, but I can't figure out how to do it now. Maybe gnome removed it?

Anyways, here's what I've tried:

#!/bin/bash
mate-terminal --tab --working-directory ~/casefile/www -e "zsh -c 'yarn dev ; exec zsh -i'"
mate-terminal --tab -e "zsh -c 'cd www ; yarn install && yarn dev ; exec zsh -i'"
mate-terminal --tab -e "zsh -i <(echo 'cd www ; yarn install && yarn dev')"

I tried a bunch of different gnome-terminal and zsh options, but honestly, I'm just flipping switches at this point without a plan.

Do you know a way it works? Thank you!

1 Like

you could install zsh
do you need to run those terminals in sequence?
you could add & to send them to the background.

2 Likes

Welcome @Michael777 to the community!

1 Like

Hi @pavlos_kairis , thanks for the reply

I want to see all their console output, in different tabs, so I know what tests/code/server/database errors are happening.

Sometimes the commands crash or wedge, so I want to ctrl-c in the tab, maybe run some commands, and run the process again in the same tab. That way, the tabs and processes stay in order, so I don't have to hunt through them.

I have mate and oh-my-zsh installed, and can open new tabs, I just don't understand how to keep them open so they are interactive.

Thanks for asking!

In testing cases, your scripts should log everything to files which you can analyze later.

I would never sit in from of the pc for hours to figure out why a compile failed.

I don't know zsh -- others could chime in.

@pavlos_kairis that's not how my development process works, but I'm glad it works for you.

Here's the script I'm using now with gnome-terminal. It opens the tabs, but when I ctrl-c yarn dev, the tab closes. Stackoverflow has a bunch of answers that don't work. I'm wondering if mate-terminal might be a better replacement. I'm using Cinnamon anyways. Thanks guys!

#!/bin/bash
gnome-terminal --tab -- bash -c "cd dev ; yarn install && yarn dev ; zsh -i"
gnome-terminal --tab -- bash -c "cd www ; yarn install && yarn dev ; zsh -i"
gnome-terminal --tab -- bash -c "cd api ; yarn install && yarn dev ; zsh -i"
gnome-terminal --tab -- bash -c "cd api ; yarn watch ; zsh -i"
gnome-terminal --tab -- bash -c "zsh -i"

Open terminal ->Edit ->profile preferences:

2 Likes

Hi @tkn you can test that with the command above and see it's closer, but doesn't remain interactive. It only offers to restart the command.

mate-terminal --tab --working-directory ~/casefile/www -e "zsh -c 'yarn dev ; exec zsh -i'"

It just holds the terminal open with the output, but doesn't enter interactive mode. It only offers to restart.

How do I open an interactive shell in a tab, and run some parameters as commands when it starts?

Yes indeed, you are right. My bad. :pensive:

No sorry, I don't know of any simple method to accomplish what you want to do. :thinking:

No problem tkn, thanks for trying!

1 Like