Feature Request: Command Palette #2860

Closed
opened 2026-01-30 23:07:21 +00:00 by claunia · 16 comments
Owner

Originally created by @yasintz on GitHub (Jul 20, 2019).

Originally assigned to: @zadjii-msft on GitHub.

Summary of the new feature/enhancement

In Profile.json we will define the actions section.

This section is an array and each element takes an Object, the schema can be

{
  "icon" : "...",
  "title" : "...",
  "command": "..."
}

You can add an icon next to the icons at the top right and make the following features.

  • A list will open.

  • Using the information in actions in Profile.json, it will create the elements of the list and execute a command when we click on it.
    I'm leaving a picture to make it more descriptive.
    Untitled

Edit : Where can we find a complete list of shortcut commands that we can use on the Windows-terminal? If there is no such place, is it possible to share in pdf or website form?

Originally created by @yasintz on GitHub (Jul 20, 2019). Originally assigned to: @zadjii-msft on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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! --> # Summary of the new feature/enhancement In Profile.json we will define the `actions` section. This section is an array and each element takes an Object, the schema can be ```json { "icon" : "...", "title" : "...", "command": "..." } ``` You can add an icon next to the icons at the top right and make the following features. - A list will open. - Using the information in `actions` in Profile.json, it will create the elements of the list and execute a command when we click on it. I'm leaving a picture to make it more descriptive. ![Untitled](https://user-images.githubusercontent.com/36041339/61579310-452c5000-ab0c-11e9-99bf-7b6e96fd8214.png) Edit : Where can we find a complete list of shortcut commands that we can use on the Windows-terminal? If there is no such place, is it possible to share in pdf or website form?
Author
Owner

@mdtauk commented on GitHub (Jul 20, 2019):

I think a list of common commands assigned to each profile, which displays as a toolbar, may be a better way. It also means the list of commands will be relevant to the profile, so no Bash commands while in Powershell.

@mdtauk commented on GitHub (Jul 20, 2019): I think a list of common commands assigned to each profile, which displays as a toolbar, may be a better way. It also means the list of commands will be relevant to the profile, so no Bash commands while in Powershell.
Author
Owner

@yasintz commented on GitHub (Jul 20, 2019):

I think a list of common commands assigned to each profile, which displays as a toolbar, may be a better way. It also means the list of commands will be relevant to the profile, so no Bash commands while in Powershell.

Are you talking about something like that? @mdtauk
Screenshot_17

@yasintz commented on GitHub (Jul 20, 2019): > I think a list of common commands assigned to each profile, which displays as a toolbar, may be a better way. It also means the list of commands will be relevant to the profile, so no Bash commands while in Powershell. Are you talking about something like that? @mdtauk ![Screenshot_17](https://user-images.githubusercontent.com/36041339/61579529-cf75b380-ab0e-11e9-8719-8f53c1d50bf3.png)
Author
Owner

@mdtauk commented on GitHub (Jul 20, 2019):

I think a list of common commands assigned to each profile, which displays as a toolbar, may be a better way. It also means the list of commands will be relevant to the profile, so no Bash commands while in Powershell.

Are you talking about something like that? @mdtauk
Screenshot_17

Those actions/commands seem more suited to a context menu, as they are specific to the Windows Terminal - I was thinking something more like


"commands": [
      {
            "icon": "appx:\\icons\\windows.png",
            "title": "WinVer",
            "command": "winver.exe"
      },
      {
            "icon": "appx:\\icons\\clear.png",
            "title": "Clear Screen",
            "command": "cls"
      }
      ],
],

@mdtauk commented on GitHub (Jul 20, 2019): > > I think a list of common commands assigned to each profile, which displays as a toolbar, may be a better way. It also means the list of commands will be relevant to the profile, so no Bash commands while in Powershell. > > Are you talking about something like that? @mdtauk > ![Screenshot_17](https://user-images.githubusercontent.com/36041339/61579529-cf75b380-ab0e-11e9-8719-8f53c1d50bf3.png) Those actions/commands seem more suited to a context menu, as they are specific to the Windows Terminal - I was thinking something more like ```json "commands": [ { "icon": "appx:\\icons\\windows.png", "title": "WinVer", "command": "winver.exe" }, { "icon": "appx:\\icons\\clear.png", "title": "Clear Screen", "command": "cls" } ], ], ```
Author
Owner

@michael-hawker commented on GitHub (Jul 22, 2019):

Would you want to duplicate the commands section per profile, or keep the icon/title the same in a central list but be able to conditionally show them based on environment or run different commands based on the environment (e.g. being able to specify cls for cmd and clear for WSL, and if you're in PS then it wouldn't appear).

@michael-hawker commented on GitHub (Jul 22, 2019): Would you want to duplicate the commands section per profile, or keep the icon/title the same in a central list but be able to conditionally show them based on environment or run different commands based on the environment (e.g. being able to specify `cls` for cmd and `clear` for WSL, and if you're in PS then it wouldn't appear).
Author
Owner

@zadjii-msft commented on GitHub (Jul 23, 2019):

Okay so this seems like it's getting close to a grab bag of feature requests. Lemme try and break this thread down so far:

  • We want a button to display the available commands (that could be bound to keybindings) and execute them from that UI.
  • We want "actions" in the profiles.json that define these actions for the UI
  • We want a possible type of "action" to be "execute this command" (which is going to end up being implemented as "send this text to the terminal as input (with or without a newline)")
  • We want a way of conditionally defining the scope of these actions, so they could appear in some profiles and not others.

Now, what I'll add is this immediately made me think of the Command Palette in VsCode and Sublime:
image

What if we added to that list:

  • Be able to fuzzy-search for commands/actions by name
  • Add a keybinding to display this UI
  • Add a setting to show/hide a button to bring up this UI

Now, lets get into some nitty-gritty details. Lets stick to just the existing keybinding commands for now. If we wanted to later add a "inputCommand" keybinding we could, but I think that's definitely blocked on work in #1142 /#1349, where we can add an arbitrary commandline to the command. I'm also going to scope this discussion to have only a global list of actions. Keybindings are global only currently, so let's just make actions global too, and save per-profile keybindings and actions for another thread.

We could theoretically define default actions for all the existing keybinding commands. With #754, we could add all the commands (that make sense) as actions to the actions list, so that everyone wouldn't need to define them manually.

An Action would be defined similarly to how you have it above:

class Action
{
    winrt::hstring Name();
    winrt::TerminalApp::ShortcutAction Command();
    winrt::hstring IconPath();
}

We'd need another structure in GlobalAppSettings to hold all these actions. I guess it could just be a std::vector<Action> in GlobalAppSettings. We'll need to make sure to roundtrip serialize them. We'll need app to be able to turn this vector into a ListView or something of actions, so that it can display this list of actions. Each element in the view would need to be intrinsically associated with the Action object it's associated with. If Action isn't a winrt type, this might be a bit more painful, but it'll mean we'll need another class to do all the serializing of them, but that's a pattern we're already using so great. Action should be a winrt type: winrt::TerminalApp::Action (maybe needs a better name).

When an element is clicked on in the list of actions, we'll need to somehow raise the event corresponding to that ShortcutAction. AppKeyBindings already does a great job of dispatching ShortcutActions, so lets re-use that. We'll pull the basic parts of dispatching ShortcutAction callbacks into another class, ShortcutActionDispatch, with a single DoAction(ShortcutAction) (name WIP) method (and events for each action). AppKeybindings will be initialized with a reference to the ShortcutActionDispatch object, so that it can call DoAction on it.

In App, when someone clicks on an item in the list, we'll get the ShortcutAction associated with that list element, and call DoAction on the app's ShortcutActionDispatch.

</spec>

@zadjii-msft commented on GitHub (Jul 23, 2019): Okay so this seems like it's getting close to a grab bag of feature requests. Lemme try and break this thread down so far: * [ ] We want a button to display the available commands (that _could_ be bound to keybindings) and execute them from that UI. * [ ] We want "actions" in the profiles.json that define these actions for the UI * [ ] We want a possible type of "action" to be "execute this command" (which is going to end up being implemented as "send this text to the terminal as input (with or without a newline)") * [ ] We want a way of conditionally defining the scope of these actions, so they could appear in some profiles and not others. Now, what I'll add is this immediately made me think of the Command Palette in VsCode and Sublime: ![image](https://user-images.githubusercontent.com/18356694/61713772-f571a280-ad1e-11e9-9650-f722797019db.png) What if we added to that list: * [ ] Be able to fuzzy-search for commands/actions by name * [ ] Add a keybinding to display this UI * [ ] Add a setting to show/hide a button to bring up this UI ----- Now, lets get into some nitty-gritty details. Lets stick to just the existing keybinding commands for now. If we wanted to later add a "inputCommand" keybinding we could, but I think that's definitely blocked on work in #1142 /#1349, where we can add an arbitrary commandline to the command. I'm also going to scope this discussion to have only a global list of actions. Keybindings are global only currently, so let's just make actions global too, and save per-profile keybindings and actions for another thread. We could theoretically define default _actions_ for all the existing keybinding commands. With #754, we could add all the commands (that make sense) as actions to the actions list, so that everyone wouldn't need to define them manually. An `Action` would be defined similarly to how you have it above: ```c++ class Action { winrt::hstring Name(); winrt::TerminalApp::ShortcutAction Command(); winrt::hstring IconPath(); } ``` We'd need another structure in GlobalAppSettings to hold all these actions. I guess it could just be a `std::vector<Action>` in `GlobalAppSettings`. We'll need to make sure to roundtrip serialize them. We'll need app to be able to turn this vector into a ListView or something of actions, so that it can display this list of actions. Each element in the view would need to be intrinsically associated with the `Action` object it's associated with. If `Action` isn't a winrt type, this might be a bit more painful, but it'll mean we'll need another class to do all the serializing of them, but that's a pattern we're already using so great. `Action` should be a winrt type: `winrt::TerminalApp::Action` (maybe needs a better name). When an element is clicked on in the list of actions, we'll need to somehow raise the event corresponding to that ShortcutAction. AppKeyBindings already does a great job of dispatching `ShortcutActions`, so lets re-use that. We'll pull the basic parts of dispatching ShortcutAction callbacks into another class, `ShortcutActionDispatch`, with a single `DoAction(ShortcutAction)` (name WIP) method (and events for each action). AppKeybindings will be initialized with a reference to the `ShortcutActionDispatch` object, so that it can call `DoAction` on it. In App, when someone clicks on an item in the list, we'll get the `ShortcutAction` associated with that list element, and call DoAction on the app's `ShortcutActionDispatch`. &lt;/spec>
Author
Owner

@zadjii-msft commented on GitHub (Jul 24, 2019):

oh no I accidentally the whole thing
image

It's certainly not polished enough to ship how it is. We might not want to ship it at all in 1.0 honestly. It would need a lot of work, starting with polishing the above comment into a proper spec. But it's certainly super neat.

@zadjii-msft commented on GitHub (Jul 24, 2019): oh no I accidentally the whole thing ![image](https://user-images.githubusercontent.com/18356694/61797959-1523cc00-adee-11e9-8c6c-a18f3ce1dc84.png) It's certainly not polished enough to ship how it is. We might not want to ship it at all in 1.0 honestly. It would need a lot of work, starting with polishing the above comment into a proper spec. But it's certainly super neat.
Author
Owner

@hbjydev commented on GitHub (Aug 8, 2019):

@zadjii-msft Any chance you could make a fork with that command palette as a branch so we can have a look at it?

@hbjydev commented on GitHub (Aug 8, 2019): @zadjii-msft Any chance you could make a fork with that command palette as a branch so we can have a look at it?
Author
Owner

@zadjii-msft commented on GitHub (Aug 8, 2019):

@haydennyyy yea you can definitely check it out if you want, but it's buggy as heck ATM. The branch is dev/migrie/f/2046-command-palette

@zadjii-msft commented on GitHub (Aug 8, 2019): @haydennyyy yea you can definitely check it out if you want, but it's buggy as heck ATM. The branch is `dev/migrie/f/2046-command-palette`
Author
Owner

@hbjydev commented on GitHub (Aug 8, 2019):

Cheers mate. :)

@hbjydev commented on GitHub (Aug 8, 2019): Cheers mate. :)
Author
Owner

@rkeithhill commented on GitHub (Sep 25, 2019):

Heh, looking at all the commands you can now bind to keyboard shortcuts, had me thinking that yeah, WindowsTerminal needs something like VSCode's command palette.

@rkeithhill commented on GitHub (Sep 25, 2019): Heh, looking at all the commands you can now bind to keyboard shortcuts, had me thinking that yeah, WindowsTerminal needs something like VSCode's command palette.
Author
Owner

@zadjii-msft commented on GitHub (Dec 9, 2019):

From @xa0082249956 in #3879

  1. User pressed Ctrl+Shift+Space, then focus moved to the Text Box automatically.
    Windows Terminal Default

  2. User typed arc.
    Typing _arc_

  3. User typed ipy instead.
    Typing _ipy_

@zadjii-msft commented on GitHub (Dec 9, 2019): From @xa0082249956 in #3879 > > 1. User pressed Ctrl+Shift+Space, then focus moved to the Text Box automatically. > <img alt="Windows Terminal Default" width="900" src="https://user-images.githubusercontent.com/9026813/70376954-7be2f580-1949-11ea-977b-36a2b2768ac8.png"> > > 2. User typed `arc`. > <img alt="Typing _arc_" width="899" src="https://user-images.githubusercontent.com/9026813/70376958-83a29a00-1949-11ea-91bf-171fc9776cf0.png"> > > 3. User typed `ipy` instead. > <img alt="Typing _ipy_" width="899" src="https://user-images.githubusercontent.com/9026813/70376909-2575b700-1949-11ea-894f-d87133f129fd.png">
Author
Owner

@hbjydev commented on GitHub (Dec 9, 2019):

Well this looks damn epic

@hbjydev commented on GitHub (Dec 9, 2019): Well this looks damn epic
Author
Owner

@pcgeek86 commented on GitHub (Jun 5, 2020):

The prototype implementation of a command palette is exactly what I would be looking for. Hope to see this in a release soon!

@pcgeek86 commented on GitHub (Jun 5, 2020): The prototype implementation of a command palette is exactly what I would be looking for. Hope to see this in a release soon!
Author
Owner

@rkeithhill commented on GitHub (Jun 6, 2020):

One "wish for" I don't see in @zadjii-msft's mini-spec is a profile.json command to open a profile picker. For example, I'd like to create this binding:

{ "command": { "action": "${command:profilePicker}", "split": "horizontal", "profile": "PowerShell" }, "keys": "alt+shift+p" }

So when I press alt+shift+p to create a new horizontal split pane, I want to see this:

image

Then after I pick the profile I want, it opens in the new pane.

BTW "${command:profilePicker} is lifted straight from VSCode debug launch file syntax. Perhaps ${profilePicker} or just profilePicker would be sufficient for Windows Terminal.

@rkeithhill commented on GitHub (Jun 6, 2020): One "wish for" I don't see in @zadjii-msft's mini-spec is a profile.json command to open a profile picker. For example, I'd like to create this binding: ``` { "command": { "action": "${command:profilePicker}", "split": "horizontal", "profile": "PowerShell" }, "keys": "alt+shift+p" } ``` So when I press `alt+shift+p` to create a new horizontal split pane, I want to see this: ![image](https://user-images.githubusercontent.com/5177512/83953578-7eda7800-a7fe-11ea-87f1-8c0b4cccd547.png) Then after I pick the profile I want, it opens in the new pane. BTW `"${command:profilePicker}` is lifted straight from VSCode debug launch file syntax. Perhaps `${profilePicker}` or just `profilePicker` would be sufficient for Windows Terminal.
Author
Owner

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

@rkeithhill Oh, don't bother with that mini-spec anymore. There's far, far more details in #5674 now 😋

There's already plans to add support for dynamically adding commands for each of your profiles or color schemes.

Then, there's also #3586, which might let us specify in the profile param to both newTab and splitPane a way of prompting the user which profile they'd like to launch. Presumably, you could add a command then which boots a tab/pane directly to that prompt.

@zadjii-msft commented on GitHub (Jun 8, 2020): @rkeithhill Oh, don't bother with that mini-spec anymore. There's far, _far_ more details in #5674 now 😋 There's already plans to add support for dynamically adding commands for each of your profiles or color schemes. Then, there's also #3586, which might let us specify in the `profile` param to both `newTab` and `splitPane` a way of prompting the user which profile they'd like to launch. Presumably, you could add a command then which boots a tab/pane directly to that prompt.
Author
Owner

@ghost commented on GitHub (Jul 22, 2020):

:tada:This issue was addressed in #6635, which has now been successfully released as Windows Terminal Preview v1.2.2022.0.🎉

Handy links:

@ghost commented on GitHub (Jul 22, 2020): :tada:This issue was addressed in #6635, which has now been successfully released as `Windows Terminal Preview v1.2.2022.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.2.2022.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2860