0

I'm working on something that requires me to run a few terminals, each with their own python virtual environment. This takes some time to open manually, so I would like to automate this setup by having a .sh file to handle it, and then leave them open ready for me to work with. I'm using Linux Mint 20.2.

For some reason I can't figure out how to write this script. I have tried various things including this:

#!/bin/bash

gnome-terminal -- /bin/sh -c 'cd ~/projects/proj/d1; exec bash'
source $(pwd)/venv/bin/activate
exec bash

gnome-terminal -- /bin/sh -c 'cd ~/projects/proj/d2; exec bash'
source $(pwd)/venv/bin/activate
exec bash

gnome-terminal -- /bin/sh -c 'cd ~/projects/proj/d3; exec bash'
source $(pwd)/venv/bin/activate
exec bash

(I am quite new to linux)

Edit: I've also tried gnome-terminal -- /bin/sh -c 'cd ~/projects/qcaas/qcaas_cloud; source $(pwd)/venv/bin/activate; exec bash', which just gives /bin/sh: 1: source: not found.

4
  • Every line after gnome-terminal is not passed to gnome-terminal, they are running in the shell you are using to execute the script
    – Panki
    Commented Sep 10, 2021 at 11:38
  • Good to know, didn't realise the significance. I made an edit to the post
    – fffrost
    Commented Sep 10, 2021 at 12:20
  • source is bash, the sh equivalent would be .
    – Panki
    Commented Sep 10, 2021 at 12:35
  • Ok, . was one of the other things I had tried. Confirmed that replacing source with . also doesn't work, it appears to not do anything, just leaves the terminal open (no errors).
    – fffrost
    Commented Sep 10, 2021 at 13:14

0

You must log in to answer this question.

Browse other questions tagged .