Ubuntu tabs open via CLI won't stay open #14070

Closed
opened 2026-01-31 04:00:05 +00:00 by claunia · 5 comments
Owner

Originally created by @Ariane-B on GitHub (May 31, 2021).

Hi! I have the following .ps1 file that's supposed to open all the terminal tabs I need to work.

wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend-srv --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend-srv --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend --suppressApplicationTitle `; new-tab -p "Ubuntu" --title dil-back-srv --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh `; new-tab -p "Ubuntu" --title dil-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `; new-tab -p "Ubuntu" --title dil-front-srv --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up `; new-tab -p "Ubuntu" --title dil-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev

(Side note, I tried, unsuccessfully, to add line breaks to this because its length is getting pretty ridiculous. Any ideas?)

My 4 first tabs stay open fine thanks to pwsh's option -noexit. The 4 last tabs, running WSL/Ubuntu, though, don't have that and they just go away. They run their commands and then disappear. In the case of the two that only run a cd command, they last a fraction of a second.

How can I ask my Ubuntu tabs not to go away?

Originally created by @Ariane-B on GitHub (May 31, 2021). Hi! I have the following `.ps1` file that's supposed to open all the terminal tabs I need to work. ```powershell wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend-srv --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend-srv --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend --suppressApplicationTitle `; new-tab -p "Ubuntu" --title dil-back-srv --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh `; new-tab -p "Ubuntu" --title dil-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `; new-tab -p "Ubuntu" --title dil-front-srv --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up `; new-tab -p "Ubuntu" --title dil-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev ``` (Side note, I tried, unsuccessfully, to add line breaks to this because its length is getting pretty ridiculous. Any ideas?) My 4 first tabs stay open fine thanks to `pwsh`'s option `-noexit`. The 4 last tabs, running WSL/Ubuntu, though, don't have that and they just go away. They run their commands and then disappear. In the case of the two that only run a `cd` command, they last a fraction of a second. How can I ask my Ubuntu tabs not to go away?
claunia added the Issue-QuestionNeeds-TriageNeeds-Tag-FixResolution-Answered labels 2026-01-31 04:00:06 +00:00
Author
Owner

@skyline75489 commented on GitHub (Jun 2, 2021):

Well you ask for cd and WSL gives a cd and then exits, which is just expected to me. How would you want the tabs not to go away? If you need bash, try wsl cd ~/somewhere ; bash.

@skyline75489 commented on GitHub (Jun 2, 2021): Well you ask for `cd` and WSL gives a `cd` and then exits, which is just expected to me. How would you want the tabs not to go away? If you need `bash`, try `wsl cd ~/somewhere ; bash`.
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2021):

Yea this seems like an answered question to me.

@zadjii-msft commented on GitHub (Jul 6, 2021): Yea this seems like an answered question to me.
Author
Owner

@Ariane-B commented on GitHub (Jul 7, 2021):

Hi! I'm sorry for the long delay. Work got very hectic.

I tried what you said, which gave me a command like this:

wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend-srv --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend-srv --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend --suppressApplicationTitle `; new-tab -p "Ubuntu" --title dil-back-srv --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh ; bash `; new-tab -p "Ubuntu" --title dil-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend ; bash `; new-tab -p "Ubuntu" --title dil-front-srv --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up ; bash `; new-tab -p "Ubuntu" --title dil-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev ; bash

That wasn't very successful. It opened a separate PowerShell window and told me three times that "/bin/bash" wasn't a file or directory.

So next I tried replacing the semicolons with && symbols. It looks like this:

wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend-srv --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend-srv --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend --suppressApplicationTitle `; new-tab -p "Ubuntu" --title dil-back-srv --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh `&`& bash `; new-tab -p "Ubuntu" --title dil-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& bash `; new-tab -p "Ubuntu" --title dil-front-srv --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up `&`& bash `; new-tab -p "Ubuntu" --title dil-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& bash

This is entirely functional! Thanks! I'm really glad you helped me reach this point.

Except there's just this one last thing: if one command fails, it never reaches the next one, and the terminal tab is frozen and unusable. Even Ctrl+C is useless. It looks like this:

image

If it fails, I'd prefer if it still launched bash and allowed me to retry the command at the appropriate time in the same tab. Is that possible?

@Ariane-B commented on GitHub (Jul 7, 2021): Hi! I'm sorry for the long delay. Work got very hectic. I tried what you said, which gave me a command like this: ```powershell wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend-srv --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend-srv --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend --suppressApplicationTitle `; new-tab -p "Ubuntu" --title dil-back-srv --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh ; bash `; new-tab -p "Ubuntu" --title dil-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend ; bash `; new-tab -p "Ubuntu" --title dil-front-srv --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up ; bash `; new-tab -p "Ubuntu" --title dil-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev ; bash ``` That wasn't very successful. It opened a separate PowerShell window and told me three times that "/bin/bash" wasn't a file or directory. So next I tried replacing the semicolons with `&&` symbols. It looks like this: ```powershell wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend-srv --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend-srv --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title backend --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title frontend --suppressApplicationTitle `; new-tab -p "Ubuntu" --title dil-back-srv --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh `&`& bash `; new-tab -p "Ubuntu" --title dil-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& bash `; new-tab -p "Ubuntu" --title dil-front-srv --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up `&`& bash `; new-tab -p "Ubuntu" --title dil-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& bash ``` This is entirely functional! Thanks! I'm really glad you helped me reach this point. Except there's just this one last thing: if one command fails, it never reaches the next one, and the terminal tab is frozen and unusable. Even Ctrl+C is useless. It looks like this: ![image](https://user-images.githubusercontent.com/6244273/124821815-2a438800-df3d-11eb-856c-213923bfe7d4.png) If it fails, I'd prefer if it still launched bash and allowed me to retry the command at the appropriate time in the same tab. Is that possible?
Author
Owner

@DHowett commented on GitHub (Jul 7, 2021):

Alright, so, this is going to get silly. Some of those ; need to be escaped so that WT doesn't attempt to parse them, as \;. If powershell ALSO needs to not parse them, this becomes...

`\;

If bash also needs to not parse them (and you're running wsl from powershell from terminal), I think you need to uh...

\\`\;

for each one that needs triple-escaping?

It's not excellent, for sure.

@DHowett commented on GitHub (Jul 7, 2021): Alright, so, this is going to get silly. Some of those `;` need to be escaped so that WT doesn't attempt to parse them, as `\;`. If powershell ALSO needs to not parse them, this becomes... ``` `\; ``` If bash also needs to not parse them (and you're running wsl from powershell from terminal), I think you need to uh... ``` \\`\; ``` for each one that needs triple-escaping? It's not excellent, for sure.
Author
Owner

@Ariane-B commented on GitHub (Jul 8, 2021):

Hi! Thanks for putting me on that trail. Turns out that was a bit too much escaping.

The correct way to escape semicolons for adding additional Bash commands ended up being:

\`;

Which makes my working long command:

wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title s-back --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title s-front --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title back --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title front --suppressApplicationTitle `; new-tab -p "Ubuntu" --title s-d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh \`; bash `; new-tab -p "Ubuntu" --title d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend \`; bash `; new-tab -p "Ubuntu" --title s-d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up \`; bash `; new-tab -p "Ubuntu" --title d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev \`; bash

And, as a bonus, I had the idea to actually prevent the error where one tab can't launch because the other is still busy in a pretty rudimentary way, using sleep.

The final result is:

wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title s-back --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title s-front --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title back --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title front --suppressApplicationTitle `; new-tab -p "Ubuntu" --title s-d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& echo -e "\nWaiting 30 seconds for Space backend to start...\n" `&`& sleep 30s `&`& ./start-compose-dev.sh \`; bash `; new-tab -p "Ubuntu" --title d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend \`; bash `; new-tab -p "Ubuntu" --title s-d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up \`; bash `; new-tab -p "Ubuntu" --title d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev \`; bash
@Ariane-B commented on GitHub (Jul 8, 2021): Hi! Thanks for putting me on that trail. Turns out that was a bit too much escaping. The correct way to escape semicolons for adding additional Bash commands ended up being: ```powershell \`; ``` Which makes my working long command: ```powershell wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title s-back --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title s-front --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title back --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title front --suppressApplicationTitle `; new-tab -p "Ubuntu" --title s-d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& ./start-compose-dev.sh \`; bash `; new-tab -p "Ubuntu" --title d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend \`; bash `; new-tab -p "Ubuntu" --title s-d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up \`; bash `; new-tab -p "Ubuntu" --title d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev \`; bash ``` And, as a bonus, I had the idea to actually prevent the error where one tab can't launch because the other is still busy in a pretty rudimentary way, using `sleep`. The final result is: ```powershell wt -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title s-back --suppressApplicationTitle pwsh -noexit -command docker-compose up `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title s-front --suppressApplicationTitle pwsh -noexit -command npm run dev `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\organizational-structure --title back --suppressApplicationTitle `; new-tab -p "PowerShell" -d C:\Users\ArianeBouchard\source\Space_FrontEnd --title front --suppressApplicationTitle `; new-tab -p "Ubuntu" --title s-d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend `&`& echo -e "\nWaiting 30 seconds for Space backend to start...\n" `&`& sleep 30s `&`& ./start-compose-dev.sh \`; bash `; new-tab -p "Ubuntu" --title d-back --suppressApplicationTitle wsl cd ~/source/dilygence-backend \`; bash `; new-tab -p "Ubuntu" --title s-d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev `&`& docker-compose up \`; bash `; new-tab -p "Ubuntu" --title d-front --suppressApplicationTitle wsl cd ~/source/dilygence-frontend-dev \`; bash ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14070