Ability to save selected text as a sendInput action #17185

Closed
opened 2026-01-31 05:34:44 +00:00 by claunia · 2 comments
Owner

Originally created by @zadjii-msft on GitHub (Apr 8, 2022).

Originally assigned to: @shubhamvrs on GitHub.

I write some long command. I need to use this frequently (or infrequently), but I don't want to have to remember all the args. I want to be able to pull it up straight from the command palette. So I want to write the command once, select it, and {perform some action}1 that lets me save it as a sendInput action.

The action should

  • immediately save it.
  • provide a UI2 for immediately editing3 the name, contents of this action, because Send "git log --graph --abbrev-commit --decorate..." to the Terminal is not useful to anyone.

Just doing the immediate save would be a good enough start on this, to the point I'd consider that an easy starter. The UI - that's Hard, for reasons listed below.

Note

Walkthrough

As an initial version of this, it's more than good enough to just save the selected text as an action without the UI. We can iterate on the UI in follow-ups.

  • Probably start with something like dev/migrie/fhl/save-command
  • We probably want to skip all the AppCommandlineArgs stuff for now. That's spicier.
  • in TerminalPage::_HandleSaveTask, we will want to try and save the current selection as a sendInput action, if there's no commandline specified.
  • AppActionHandlers.cpp has plenty of examples of getting the active control. Should be easy enough to get the selected text from it.
  • We'll probably want to generate the name of this action (without a commandline) as "Save Task..."
  • Over and above: It would be valuable to Toast the user with a message "Saved selected text as a new action". TerminalPage::IdentifyWindow has an example of a Toast

  1. Obviously, easiest way is via cmdpal or keybinding. Also consider a right-click context menu entry, #3337 ↩︎

  2. This has it's own challenges. It can't be a ContentDialog (https://github.com/microsoft/microsoft-ui-xaml/issues/3804). It could be nested in a Flyout, maybe. Hopefully the dialog thing is limited just to ContentDialogs and not all Flyouts. It probably shouldn't be a TeachingTip (#12798). We could roll our own ContentDialog for this of course (#11308). ↩︎

  3. Might be tricky - we'd have to hand on to an instance of the actual Command itself, so we can edit it... in place? and hopefully writing to the settings would then just refresh all the other name->command maps instantly. ↩︎

Originally created by @zadjii-msft on GitHub (Apr 8, 2022). Originally assigned to: @shubhamvrs on GitHub. I write some long command. I need to use this frequently (or infrequently), but I don't want to have to remember all the args. I want to be able to pull it up straight from the command palette. So I want to write the command once, select it, and {perform some action}[^1] that lets me save it as a `sendInput` action. The action should * immediately save it. * provide a UI[^2] for immediately editing[^3] the name, contents of this action, because `Send "git log --graph --abbrev-commit --decorate..." to the Terminal` is not useful to anyone. Just doing the immediate save would be a good enough start on this, to the point I'd consider that an easy starter. The UI - that's **H**ard, for reasons listed below. > **Note** > ## Walkthrough As an initial version of this, it's more than good enough to just save the selected text as an action without the UI. We can iterate on the UI in follow-ups. * Probably start with something like [`dev/migrie/fhl/save-command`](https://github.com/microsoft/terminal/compare/6f5b9fb...1cde67ac466e19394eea1eb3a41405513d160a6f) * We probably want to skip all the `AppCommandlineArgs` stuff for now. That's spicier. * in `TerminalPage::_HandleSaveTask`, we will want to try and save the current selection as a `sendInput` action, if there's no `commandline` specified. * AppActionHandlers.cpp has plenty of examples of getting the active control. Should be easy enough to get the selected text from it. * We'll probably want to generate the name of this action (without a commandline) as "Save Task..." * Over and above: It would be valuable to `Toast` the user with a message "Saved selected text as a new action". `TerminalPage::IdentifyWindow` has an example of a `Toast` [^1]: Obviously, easiest way is via cmdpal or keybinding. Also consider a right-click context menu entry, #3337 [^2]: This has it's own challenges. It can't be a `ContentDialog` (https://github.com/microsoft/microsoft-ui-xaml/issues/3804). It could be nested in a `Flyout`, maybe. Hopefully the dialog thing is limited just to ContentDialogs and not all Flyouts. It probably shouldn't be a `TeachingTip` (#12798). We _could_ roll our own ContentDialog for this of course (#11308). [^3]: Might be tricky - we'd have to hand on to an instance of the actual `Command` itself, so we can edit it... in place? and hopefully writing to the settings would then just refresh all the other name->command maps instantly.
Author
Owner

@shubhamvrs commented on GitHub (Aug 10, 2023):

/assign

@shubhamvrs commented on GitHub (Aug 10, 2023): /assign
Author
Owner

@Ben-EJ commented on GitHub (Dec 4, 2023):

Can I work on this? : )

@Ben-EJ commented on GitHub (Dec 4, 2023): Can I work on this? : )
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17185