terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Allow for ExecuteCommandline actions to be called straight from the commandline

Open zadjii-msft opened this issue 4 years ago • 6 comments

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

zadjii-msft avatar Apr 29 '21 21:04 zadjii-msft

ANOTHER ACTION BINDING PLACE :D

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

DHowett avatar Apr 29 '21 22:04 DHowett

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

you better believe it

zadjii-msft avatar Apr 29 '21 23:04 zadjii-msft

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 avatar Sep 08 '21 02:09 zadjii-msft

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 avatar Feb 17 '22 16:02 NeilMacMullen

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 avatar Feb 17 '22 16:02 zadjii-msft

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

stianhoiland avatar Nov 26 '25 02:11 stianhoiland