Execute default commands => terminal launch or new tab #10411

Closed
opened 2026-01-31 02:20:51 +00:00 by claunia · 3 comments
Owner

Originally created by @V1NAY8 on GitHub (Aug 31, 2020).

Description of the new feature/enhancement

  • I want a terminal configuration where I should be able to run a command automatically on launching it.
  • No need to check if the command is working.
  • Support for multiple commands.

Whom this is helpful for?

  • Developers who want to setup environment using script. ( ./runWhileTerminalLaunches.sh)
  • Execute git any commands (git fetch --dry-run)

Proposed technical implementation details (optional)

For Example:

  • Consider a Scenario using python virtual environment.
  • So each time opening a new tab, a command has to be executed to activate the virtual environment.
  • Assume I created a virtualenv for python named venv.
  • In settings.json add "defaultCommand" along with the command to execute
{
    "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
    "hidden": false,
    "name": "Ubuntu",
    "source": "Windows.Terminal.Wsl",
    "defaultCommand": "source /mnt/c/Work/venv/bin/activate"
}
  • So when I open a new tab it runs the command and sets my environment.
source /mnt/c/Work/venv/bin/activate
(venv)
Originally created by @V1NAY8 on GitHub (Aug 31, 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 - I want a terminal configuration where I should be able to run a command automatically on launching it. - No need to check if the command is working. - Support for multiple commands. ### Whom this is helpful for? - Developers who want to setup environment using script. ( ./runWhileTerminalLaunches.sh) - Execute git any commands (git fetch --dry-run) # Proposed technical implementation details (optional) For Example: - Consider a Scenario using python virtual environment. - So each time opening a new tab, a command has to be executed to activate the virtual environment. - Assume I created a virtualenv for python named **venv**. - In settings.json add "defaultCommand" along with the command to execute ```json { "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", "hidden": false, "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "defaultCommand": "source /mnt/c/Work/venv/bin/activate" } ``` - So when I open a new tab it runs the command and sets my environment. ```bash source /mnt/c/Work/venv/bin/activate (venv) ```
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 02:20:51 +00:00
Author
Owner

@WSLUser commented on GitHub (Aug 31, 2020):

Have you read https://docs.microsoft.com/en-us/windows/terminal/tutorials/ssh?

So "commandline": "source /mnt/c/Work/venv/bin/activate"

Pro tip: Before filing an issue, check the docs first to see if it addresses your issue. If not, then search the issues to see if there's already an existing issue. If it's a feature, add a thumps up to the OP.

@WSLUser commented on GitHub (Aug 31, 2020): Have you read https://docs.microsoft.com/en-us/windows/terminal/tutorials/ssh? So `"commandline": "source /mnt/c/Work/venv/bin/activate"` Pro tip: Before filing an issue, check the docs first to see if it addresses your issue. If not, then search the issues to see if there's already an existing issue. If it's a feature, add a thumps up to the OP.
Author
Owner

@V1NAY8 commented on GitHub (Sep 1, 2020):

@WSLUser
I think it only works with ssh.
I am trying to execute a command in WSL 2 in Ubuntu with the following:
settings.json

            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "fontFace": "MesloLGS NF",
                "commandline": "source /mnt/c/Work/venv/bin/activate"
            }

image

@V1NAY8 commented on GitHub (Sep 1, 2020): @WSLUser I think it only works with ssh. I am trying to execute a command in WSL 2 in Ubuntu with the following: settings.json ```json { "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", "hidden": false, "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "fontFace": "MesloLGS NF", "commandline": "source /mnt/c/Work/venv/bin/activate" } ``` ![image](https://user-images.githubusercontent.com/33659563/91800106-0725b900-ec46-11ea-9fb8-96d5dbdbf0d5.png)
Author
Owner

@DHowett commented on GitHub (Sep 1, 2020):

We will not be offering startup commands, because they are wildly different for every shell. Look up how to start cmd, or powershell, or bash, or zsh, or ssh (which will later spawn one of the above shells) and configure your profile to launch that shell with the command pre-seeded. This is easy for users to configure because they know what shell they’re using, but hard for us to offer because we do not.

@DHowett commented on GitHub (Sep 1, 2020): We will not be offering startup commands, because they are wildly different for every shell. Look up how to start cmd, or powershell, or bash, or zsh, or ssh (which will later spawn one of the above shells) and configure your profile to launch that shell with the command pre-seeded. This is easy for users to configure because they know what shell they’re using, but hard for us to offer because we do not.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10411