Run multiple commands on startup in profiles #8991

Closed
opened 2026-01-31 01:43:08 +00:00 by claunia · 4 comments
Owner

Originally created by @WesDowney on GitHub (Jun 12, 2020).

Description of the new feature/enhancement

Provide the ability in settings.json for an individual profile to run multiple commands at startup.

Currently: commandline allows for one command.

Proposed: Allow an array of commands to run.

Sample use case: vagrant up && vagrant ssh. You currently can't put this in commandline. Allowing multiple commands easily set up in settings.json would make it easier to automate things.

Proposed technical implementation details (optional)

commandline could accept an array instead or a new field could be added to settings.json called commandlines that accepts an array. As the commands run, it should only run the next command if the previous was successful.

Currently I think the only way to run multiple commands is to make a script and tell commandline to run the script. This is messier because you have to deal with more files and then everything you need isn't all in one spot.

Originally created by @WesDowney on GitHub (Jun 12, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Provide the ability in `settings.json` for an individual profile to run multiple commands at startup. Currently: `commandline` allows for one command. Proposed: Allow an array of commands to run. Sample use case: `vagrant up && vagrant ssh`. You currently can't put this in `commandline`. Allowing multiple commands easily set up in `settings.json` would make it easier to automate things. <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) `commandline` could accept an array instead or a new field could be added to settings.json called `commandlines` that accepts an array. As the commands run, it should only run the next command if the previous was successful. Currently I think the only way to run multiple commands is to make a script and tell `commandline` to run the script. This is messier because you have to deal with more files and then everything you need isn't all in one spot. <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Jun 15, 2020):

What if you tried something like cmd /k vagrant up && vagrant ssh?

@zadjii-msft commented on GitHub (Jun 15, 2020): What if you tried something like `cmd /k vagrant up && vagrant ssh`?
Author
Owner

@WesDowney commented on GitHub (Jun 16, 2020):

This works great! Thank you

@WesDowney commented on GitHub (Jun 16, 2020): This works great! Thank you
Author
Owner

@volviq commented on GitHub (Mar 5, 2023):

Unfortunately this doesn't seem to work in a Powershell commandline.
"commandline": "%windir%/System32/WindowsPowerShell/v1.0/powershell.exe -ExecutionPolicy ByPass -NoExit -Command C:/Users/Simon/miniconda3/shell/condabin/conda-hook.ps1 && conda activate",
would fail. Is this worth another issue?

@volviq commented on GitHub (Mar 5, 2023): Unfortunately this doesn't seem to work in a Powershell commandline. "commandline": "%windir%/System32/WindowsPowerShell/v1.0/powershell.exe -ExecutionPolicy ByPass -NoExit -Command C:/Users/Simon/miniconda3/shell/condabin/conda-hook.ps1 && conda activate", would fail. Is this worth another issue?
Author
Owner

@MBTayeb commented on GitHub (Jul 30, 2023):

@volviq Thank god, I found out that it works using :)
&&;
In my case:
"cmd.exe /K C:\Users\User\anaconda3\Scripts\activate.bat &&; conda activate env"

@MBTayeb commented on GitHub (Jul 30, 2023): @volviq Thank god, I found out that it works using :) &&; In my case: "cmd.exe /K C:\\Users\\User\\anaconda3\\Scripts\\activate.bat &&; conda activate env"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8991