Allow for ExecuteCommandline actions to be called straight from the commandline #13670

Open
opened 2026-01-31 03:48:55 +00:00 by claunia · 6 comments
Owner

Originally created by @zadjii-msft on GitHub (Apr 29, 2021).

So I can do something like wt good-morning and have it immediately start up with my Good Morning actions. Maybe something like

{
  "command": {
    "action": "wt",
    "subcommand": "good-morning",
    "commandline": "nt ; sp"
  },
  "name": "Good Morning"
},

that lets the given commandline be treated as the provided commandline.

I suppose:

  • does it have to be limited to wt actions?
  • what happens for wt good-morning ; new-tab?
  • does { "command": {"action": "wt", "subcommand": "gm", "commandline": "good-morning" } } work?

Also relevant: #6899, #6899 - Action IDs.md

Originally created by @zadjii-msft on GitHub (Apr 29, 2021). So I can do something like `wt good-morning` and have it immediately start up with my `Good Morning` actions. Maybe something like ```json { "command": { "action": "wt", "subcommand": "good-morning", "commandline": "nt ; sp" }, "name": "Good Morning" }, ``` that lets the given commandline be treated as the provided commandline. I suppose: * does it have to be limited to `wt` actions? * what happens for `wt good-morning ; new-tab`? * does `{ "command": {"action": "wt", "subcommand": "gm", "commandline": "good-morning" } }` work? Also relevant: #6899, [#6899 - Action IDs.md](https://github.com/microsoft/terminal/blob/main/doc/specs/%236899%20-%20Action%20IDs/%236899%20-%20Action%20IDs.md)
claunia added the Issue-FeatureProduct-TerminalArea-Commandline labels 2026-01-31 03:48:55 +00:00
Author
Owner

@DHowett commented on GitHub (Apr 29, 2021):

ANOTHER ACTION BINDING PLACE :D

(did this move from 9990 because it was less momentous)

@DHowett commented on GitHub (Apr 29, 2021): ANOTHER ACTION BINDING PLACE :D (did this move from 9990 because it was less momentous)
Author
Owner

@zadjii-msft commented on GitHub (Apr 30, 2021):

(did this move from 9990 because it was less momentous)

you better believe it

@zadjii-msft commented on GitHub (Apr 30, 2021): > (did this move from 9990 because it was less momentous) you better believe it
Author
Owner

@zadjii-msft commented on GitHub (Sep 8, 2021):

From @Rosefield in #11108:

Description of the new feature/enhancement

Currently the Command Palette shows me all of the actions that I can run, including custom ones that I have made. It would be nice to also be able to run those actions from the command line. E.g. if I have a saved action

{ "name": "Create My Layout", "command": { ... }}

I would like to be able to call it directly like wt "Create My Layout" or as part of multiple commands wt sp; sp; myAction

Proposed technical implementation details (optional)

Currently the command line parser has a subset of all possible actions as hardcoded allowed commands. The easiest thing might be to add as a special "named action" command for if the command fails to parse as something else, or more drastically make the command parser depend on the settings so it can look up actions directly.

Additionally:

Looks similar enough so there is an opportunity for merging. Maybe I am reading it wrong, but I think this extends that idea in that this allows more possibilities, e.g.
choosing which window wt -w 0 MyAction, wt -w new MyAction, etc. Composition of the commands seems to be covered or at least mentioned in the other issue.

I think it would also potentially be weird to require separate command line and normal actions. Maybe the root issue is that the commandline doesn't support as many of the actions as during normal operation?

@zadjii-msft commented on GitHub (Sep 8, 2021): From @Rosefield in #11108: > # Description of the new feature/enhancement > Currently the Command Palette shows me all of the actions that I can run, including custom ones that I have made. It would be nice to also be able to run those actions from the command line. E.g. if I have a saved action > > ``` > { "name": "Create My Layout", "command": { ... }} > ``` > > I would like to be able to call it directly like `wt "Create My Layout"` or as part of multiple commands `wt sp; sp; myAction` > > # Proposed technical implementation details (optional) > Currently the command line parser has a subset of all possible actions as hardcoded allowed commands. The easiest thing might be to add as a special "named action" command for if the command fails to parse as something else, or more drastically make the command parser depend on the settings so it can look up actions directly. Additionally: > Looks similar enough so there is an opportunity for merging. Maybe I am reading it wrong, but I think this extends that idea in that this allows more possibilities, e.g. > choosing which window `wt -w 0 MyAction`, `wt -w new MyAction`, etc. Composition of the commands seems to be covered or at least mentioned in the other issue. > > I think it would also potentially be weird to require separate command line and normal actions. Maybe the root issue is that the commandline doesn't support as many of the actions as during normal operation?
Author
Owner

@NeilMacMullen commented on GitHub (Feb 17, 2022):

Adding a vote for this. I arrived here because I was looking for a way to select a random tab-color or theme from my powershell profile at startup. (i.e. I'd like each new tab to be visually distinct without any user intervention).

In that particular case it's interesting to consider whether it would be useful to be able to pass in a color from the shell rather than just invoking a particular command to "set-tab-blue". FWIW I'd be be happy to compose the JSON object in the same format as used by settings. E.g.

wt invoke-action "{ ""action"": ""setTabColor"", ""color"": ""$myColor"" }"

@NeilMacMullen commented on GitHub (Feb 17, 2022): Adding a vote for this. I arrived here because I was looking for a way to select a random tab-color or theme from my powershell profile at startup. (i.e. I'd like each new tab to be visually distinct without any user intervention). In that particular case it's interesting to consider whether it would be useful to be able to pass in a color from the shell rather than just invoking a particular command to "set-tab-blue". FWIW I'd be be happy to compose the JSON object in the same format as used by settings. E.g. `wt invoke-action "{ ""action"": ""setTabColor"", ""color"": ""$myColor"" }"`
Author
Owner

@zadjii-msft commented on GitHub (Feb 17, 2022):

FWIW I'd be be happy to compose the JSON object in the same format as used by settings. E.g.

wt invoke-action "{ ""action"": ""setTabColor"", ""color"": ""$myColor"" }"

that's actually a really neat idea. We'd have to square that with the windowing behavior - like wt -w 0 invoke-action ... makes sense, but...

well I guess it actually would work kinda the same as it does today. Unless the first action in invoke-action is a newTab, then we'd imply the new-tab action, then the passed in action. So we'd probably want to support both wt invoke-action { action } and wt invoke-action [ {action},... ] (as best as that's possible)

@zadjii-msft commented on GitHub (Feb 17, 2022): > FWIW I'd be be happy to compose the JSON object in the same format as used by settings. E.g. > > `wt invoke-action "{ ""action"": ""setTabColor"", ""color"": ""$myColor"" }"` that's actually a really neat idea. We'd have to square that with the windowing behavior - like `wt -w 0 invoke-action ...` makes sense, but... well I guess it actually would work kinda the same as it does today. Unless the first action in `invoke-action` is a newTab, then we'd imply the `new-tab` action, then the passed in action. So we'd probably want to support both `wt invoke-action { action }` and `wt invoke-action [ {action},... ]` (as best as that's possible)
Author
Owner

@stianhoiland commented on GitHub (Nov 26, 2025):

Big +1 for this! Maketh the terminal like whence it came: scriptable, programmable, automatable. Moar power!

@stianhoiland commented on GitHub (Nov 26, 2025): Big +1 for this! Maketh the terminal like whence it came: scriptable, programmable, automatable. Moar power!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13670