Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Scripts Panel #1595

Closed
Tracked by #13445
nick22985 opened this issue Jun 25, 2019 · 8 comments · Fixed by #15664
Closed
Tracked by #13445

Feature Request - Scripts Panel #1595

nick22985 opened this issue Jun 25, 2019 · 8 comments · Fixed by #15664
Labels
A11yMAS Accessibility tracking Area-User Interface Issues pertaining to the user interface of the Console or Terminal Disability-All Accessibility tracking In-PR This issue has a related PR InclusionBacklog Accessibility tracking InclusionBacklog-Windows TerminalWin32 Accessibility tracking Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.

Comments

@nick22985
Copy link

Type the same commands multiple times or using external files from the terminal application to launch scripts. This feature would solve the problem of users alt tabbing allot of the time to run scripts where it could be in built in the terminal as an added option to make a side panel appear or something similar to that to show scripts and run them.

I want a panel to have toggle or an additional option so you can have a panel or something similar to be attached to the terminal so that you can run scripts from terminal and do not have to go into windows and search for scripts. This would kind of be like the the powershell ISE commands panel that you can toggle on but it would be for multiple terminals and you can set what you want to run their and the commands or scripts that you run all the time.

PowerShell ISE

@nick22985 nick22985 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 25, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 25, 2019
@JushBJJ
Copy link

JushBJJ commented Jun 25, 2019

panes are comimg into the terminal soon, well its already within the code, its just unfinished

@JushBJJ
Copy link

JushBJJ commented Jun 25, 2019

#1000

@DHowett-MSFT DHowett-MSFT added the Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. label Jun 28, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 28, 2019
@zadjii-msft
Copy link
Member

Actually, I'm gonna re-open this. This is a not terrible idea for an extension, similar to #644

@zadjii-msft zadjii-msft reopened this Jul 2, 2019
@zadjii-msft zadjii-msft added Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Product-Terminal The new Windows Terminal. and removed Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. labels Jul 2, 2019
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jul 2, 2019
@bitcrazed bitcrazed removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jul 2, 2019
@zadjii-msft
Copy link
Member

zadjii-msft commented Sep 18, 2021

Adding some other comments from other duped threads:

@ThatWionGuy in #5273:

There are many commands that I either use frequently and some I use only once and a while but not frequently enough to memorize them. It would be nice if there was a way to store these and then access them from the terminal app to be executed when needed. A perfect example of this is the command to see all globally installed npm packages:

npm list -g --depth 0

I do this at least once a month which is just long enough to forget the exact line, so then I have to open Google and search for the command again, copy it and paste it into the terminal, which takes up time I should be using for other things.

The best way to keep a user engaged is to keep them from having to leave your app. By providing a way to quickly execute commands inside the terminal app, you allow users to be more productive and spend less time changing apps.

General Idea

What I am thinking would be an aside on the left or right of the window. Would be hidden by default but able to be shown through the main menu or keyboard shortcut. Could be called Favorites, Shortcuts or Quick List the naming is completely up to you, but for consistency and ease of explanation I will refer to it as "favorites" through the rest of this proposal.

It would display these favorite commands where the user could just click on one of them and the app would input the command into the active terminal. The panel would be scoped to the current active terminal i.e. a cmd terminal would show the favorites for cmd, and if the user switched to a powershell terminal then the favorites would switch to powershell favorites.

windows-terminal-favorites
Image is a wireframe not a polished UI

Proposed technical implementation details (optional)

Management of these favorites could be accomplished in the profiles section of the settings file, so no need to make a fancy GUI to manage the favorites. It could be structured something like this:

...
"profiles" : 
    [
        {
            ...,
            "favorites" : [
                 {
                     "name" : "List global npm packages",
                     "command" : "npm list -g --depth 0",
                     "auto-run" : false
                 }
            ],
        },
        ...
    ]
    ...
}

Property Type Usage
name string What shows up in the aside panel
command string What to inject into the terminal when clicked
auto-run (optional) boolean Whether to run the command or just input into the terminal. Default to false.
Since the user enters them in the profile settings there is no need to manage whether the command is actually a windows cmd, valid powershell or valid bash command... it is up to the user to put the favorites into the correct profile, correct order and to put valid commands. Terminal app would just display the list of favorites sorted by array order, based on the currently active profile and inject/execute the commands when they were clicked. Also since they are defined in the profiles the look and feel of the aside could match the profiles theme.

There would also need to be some kind of message to display if there are no current favorites for a profile. Something like "You currently have no favorites for this profile." and maybe a link to add a favorite which would open the settings file with a new favorite stubbed out.

The injection/execution could easily be accomplished in a variety of ways depending on the level of access to the underlying terminal that the app has (I will be honest, I have not looked into the code a lot) But even if you had to do it via sending the keystrokes to the underlying terminal and if auto-run is true sending a Enter Key at the end would be basically no different than the app typing the command for the user.

I am really not trying to completely design it out for you... just trying to give a general feature proposal so if you think of a better design and do it completely different I would not be offended, just wish that a feature like this existed.

Possible future enhancements

Initially just displaying the list, allowing injection/execution of the commands on click and management through the settings would allow this feature to be functional and useful to users. But if desired, future enhancements could be added that would only provide better usability such as:

  • Change sort order by drag and drop in aside.
  • Add new favorite via GUI (Dialog, or integrated UI)
  • Add new favorite from last executed command.
  • Group Commands into collapsible sections for better organization.
  • Support executing multiple commands on a single click.

Again these would be nice to haves later, but in no way necessary to provide a usable feature that provides value to the user.


_ @zadjii-msft in #5273 _:

I think this is an excellent extension idea. It's actually something I've been toying around with for a long time, but you've actually written up lots of the ideas I've had 😅.

I'm going to mark this up as an extension, and toss it onto the backlog.

I've personally been working on a tool that does a lot of similar things to what you're requesting, just straight from the commandline as opposed to as a part of the UI.

image

You can check it out over at zadjii/keep. Admittedly, I only update it when I feel the itch, and it only works for CMD, but it works for me ¯\_(ツ)_/¯

</shameless self-plug>

My own personal goal is to get the Terminal to a place where I can integrate a bunch of the features from that helper tool more directly into the UI. I've been thinking of doing it with a combination of:

One way or not, this is an excellent addition to my collection of extension ideas. Thanks!


_ @MrGolden1 in #11270 _:

I think this is very useful that there would be an option for saved commands/scripts in windows terminal.

for instance I need to ssh to a server several times a day or set a vpn at beginning of my work. or there is maybe many commands that we use hardly and we don't memorize them, such as resting database, special git command, changing an option in OS and many other things ....
It would be great if we could pick the command we want from an easy accessible place inside of windows terminal. Add, remove, titling, editing before run, pin, most recent and most used commands can be good options for it too.

Proposed technical implementation details (optional)

This picture is just for visualize my idea. (I found nothing better than windows clipboard :))
image

There is a panel such this that commands are listed in.

Thanks in advanced.

@mws-rmain
Copy link

The 'scripts panel' that starts this thread is great for indexing/retaining/invoking a massive library of scripts. Later suggestions are closer to my needs: frequently accessing a (more limited, but commonly used) set of commands or executables (batch files/shell scripts/python/etc.).

I'd like to see one step further in terms of simplification (since UI elements is on the roadmap for extensions): a generic toolbar which contains 'buttons' that are linked to specific commands or executables. The profile structure suggested in #5273 could be extended to support the configuration of the toolbar (also add an 'icon' for quick & easy locating of specific buttons). I'm thinking the end result would be something akin to Chrome's 'Bookmarks' toolbar. Once defined, your favorite commands are one click away!

As a next-level of difficulty, other elements could be added to add variability to toolbar items, such as a listbox to select one of several 'user profiles' when logging into ssh, or a textbox to enter a variable to pass on the command line to the script invoked by the associated button, etc.

@zadjii-msft
Copy link
Member

I'm thinking the end result would be something akin to Chrome's 'Bookmarks' toolbar

I think we've actually got a good mental model on the team (if albeit not formally communicated) of how this is going to end up working. We've got our plan for action ID's, and customizing the dropdown with those action IDs (#1571). The "bookmarks bar" would just be the same kind of thing, with different UI. It's just another place that users can bind actions to a button. So opening specific profiles, running commands, all those could be bound to those buttons. (see also #2934, #4531)


Moving some relevant discussion from #6412:

I think there is important point that everyone is missing when telling us to rely on the shell completion functions. I want to be able to use snippets that are independent of the shell configuration. As an example, I often run awk '{ print $1 }' | while read... on server where I cannot create aliases or change any config, I would like to be able to type in 'a$1' for example and expand it to the predefined snippet. I'm often connecting to the systems where the completion is fully disabled and I run a lot of repetitive task that can't be scripted (terminal hijacking is always disabled). I'm really convinced this is a needed feature.

You could also theoretically create a command like:

{ "command": { "action": "sendInput", "input": "awk '{ print $1 }' | while read...\r" }, "keys":"ctrl+a", "name": "a$1" },

and then you could use the command palette to send that snippet really simply. So you'd just press Ctrl+Shift+P (to open the command palette),a,$,1,enter and it'd send that snippet to the terminal. Or leave out the \r to just input it on the prompt, but not submit. Kinda similar, and shell/backend agnostic.

@zadjii-msft zadjii-msft modified the milestones: Terminal Backlog, Backlog Jan 4, 2022
@zadjii-msft
Copy link
Member

zadjii-msft commented Jun 14, 2022

Note to self: I'm gonna start using this thread for the "input actions" mode of the command palette. I've had notes all over, but I'm copying bits here for tracking

see: #5400, #12857, and to a lesser extent #3121

Like, what if you just had a list of all your saved commands right there, to send to the terminal?

I reference #3121, since it would make sense to have these all relative to where the input currently is (right)?

And then the many follow ups:

  • can we load that up with the MRU working directories of the terminal?
  • can we somehow pre-filter that with what's on the commandline, assuming that there's a FTCS mark indicating the start of the commandline? so, git c {savedCommands} would only show the things that start with "git c", and would only send ommit
  • Ability to save selected text as a sendInput action #12857 saveInput action, accepts a name for the command, and a commandline for the input
    • Without a name, it opens a TeachingTip, like the window renamer
  • wt save [--name name] [commandline] to save a commandline as a sendInput action.
  • A crazy person would have sets of commands that could populate this menu:
    • the global ones in actions
    • the per-profile ones
    • the ones that are found by looking for a commands.json (or whatever) in the CWD of the shell (and upwards till /), for workspace-provided actions
  • more...

@zadjii-msft zadjii-msft modified the milestones: Backlog, Up Next Jun 14, 2022
@zadjii-msft zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal and removed Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. labels Jun 14, 2022
@zadjii-msft zadjii-msft added this to Spec Needed ❓ in Specification Tracker via automation Jun 14, 2022
@zadjii-msft zadjii-msft added InclusionBacklog Accessibility tracking InclusionBacklog-Windows TerminalWin32 Accessibility tracking A11yMAS Accessibility tracking Disability-All Accessibility tracking labels Jun 16, 2022
@zadjii-msft zadjii-msft moved this from Spec Needed ❓ to Spec In Progress ✏ in Specification Tracker Nov 4, 2022
@zadjii-msft zadjii-msft moved this from Spec In Progress ✏ to Spec In Review ⏰ in Specification Tracker Feb 17, 2023
@zadjii-msft zadjii-msft modified the milestones: Up Next, Terminal v1.19 May 12, 2023
@swiffer
Copy link

swiffer commented Jun 25, 2023

The Initial wireframes Look similar to what ist available in Warp (Warp Drive Workflows)

https://docs.warp.dev/features/warp-drive/workflows

Having These Concepts directly integrated into the terminal (ai as Well) feels really great!

zadjii-msft added a commit that referenced this issue Aug 14, 2023
There's two parts to this PR that should be considered _separately_.
1. The Suggestions UI, a new graphical menu for displaying suggestions /
completions to the user in the context of the terminal the user is
working in.
2. The VsCode shell completions protocol. This enables the shell to
invoke this UI via a VT sequence.

These are being introduced at the same time, because they both require
one another. However, I need to absolutely emphasize:

### THE FORMAT OF THE COMPLETION PROTOCOL IS EXPERIMENTAL AND SUBJECT TO
CHANGE

This is what we've prototyped with VsCode, but we're still working on
how we want to conclusively define that protocol. However, we can also
refine the Suggestions UI independently of how the protocol is actually
implemented.

This will let us rev the Suggestions UI to support other things like
tooltips, recent commands, tasks, INDEPENDENTLY of us rev'ing the
completion protocol.

So yes, they're both here, but let's not nitpick that protocol for now. 

### Checklist

* Doesn't actually close anything
* Heavily related to #3121, but I'm not gonna say that's closed till we
settle on the protocol
* See also:
  * #1595
  * #14779
  * microsoft/vscode#171648

### Detailed Description

#### Suggestions UI

The Suggestions UI is spec'ed over in #14864, so go read that. It's
basically a transient Command Palette, that floats by the user's cursor.
It's heavily forked from the Command Palette code, with all the business
about switching modes removed. The major bit of new code is
`SuggestionsControl::Anchor`. It also supports two "modes":
* A "palette", which is like the command palette - a list with a text
box
* A "menu", which is more like the intellisense flyout. No text box.
This is the mode that the shell completions use

#### Shell Completions Protocol

I literally cannot say this enough times - this protocol is experimental
and subject to change. Build on it at your own peril. It's disabled in
Release builds (but available in preview behind
`globals.experimental.enableShellCompletionMenu`), so that when it
ships, no one can take a dependency on it accidentally.

Right now we're just taking a blob of JSON, passing that up to the App
layer, who asks `Command` to parse it and build a list of `sendInput`
actions to populate the menu with. It's not a particularly elegant
solution, but it's good enough to prototype with.

#### How do I test this?

I've been testing this in two parts. You'll need a snippet in your
powershell profile, and a keybinding in the Terminal settings to trigger
it. The work together by binding <kbd>Ctrl+space</kbd> to _essentially_
send <kbd>F12</kbd><kbd>b</kbd>. Wacky, but it works.

```json
{ "command": { "action": "sendInput","input": "\u001b[24~b" }, "keys": "ctrl+space" },
```

```ps1
function Send-Completions2 {
  $commandLine = ""
  $cursorIndex = 0
  # TODO: Since fuzzy matching exists, should completions be provided only for character after the
  #       last space and then filter on the client side? That would let you trigger ctrl+space
  #       anywhere on a word and have full completions available
  [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$commandLine, [ref]$cursorIndex)
  $completionPrefix = $commandLine

  # Get completions
  $result = "`e]633;Completions"
  if ($completionPrefix.Length -gt 0) {
    # Get and send completions
    $completions = TabExpansion2 -inputScript $completionPrefix -cursorColumn $cursorIndex
    if ($null -ne $completions.CompletionMatches) {
      $result += ";$($completions.ReplacementIndex);$($completions.ReplacementLength);$($cursorIndex);"
      $result += $completions.CompletionMatches | ConvertTo-Json -Compress
    }
  }
  $result += "`a"

  Write-Host -NoNewLine $result
}

function Set-MappedKeyHandlers {
  # VS Code send completions request (may override Ctrl+Spacebar)
  Set-PSReadLineKeyHandler -Chord 'F12,b' -ScriptBlock {
    Send-Completions2
  }
}

# Register key handlers if PSReadLine is available
if (Get-Module -Name PSReadLine) {
  Set-MappedKeyHandlers
}

```


### TODO

* [x] `(prompt | format-hex).`<kbd>Ctrl+space</kbd> -> This always
throws an exception. Seems like the payload is always clipped to

```{"CompletionText":"Ascii","ListItemText":"Ascii","ResultType":5,"ToolTip":"string
Ascii { get```
  and that ain't JSON. Investigate on the pwsh side?
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Aug 15, 2023
zadjii-msft added a commit that referenced this issue Aug 15, 2023
_targets #15027_

Adds a new suggestion source, `tasks`, that allows a user to open the
Suggestions UI with `sendInput` commands saved in their settings.
`source` becomes a flag setting, so it can be combined like so:

```json
        {
            "keys": "ctrl+shift+h", "command": { "action": "suggestions", "source": "commandHistory", "useCommandline":true },
        },
        {
            "keys": "ctrl+shift+y", "command": { "action": "suggestions", "source": "tasks", "useCommandline":false },
        },
        {
            "keys": "ctrl+shift+b", "command": { "action": "suggestions", "source": ["all"], "useCommandline":true },
        },
```

If a nested command has `sendInput` commands underneath it, this will
build a tree of commands that only include `sendInput`s as leaves (but
leave the rest of the nesting structure intact).


## References and Relevant Issues

Closes #1595

See also #13445 
As spec'd in #14864 

## Validation Steps Performed

Tested manually
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Aug 15, 2023
zadjii-msft added a commit that referenced this issue Oct 5, 2023
## Summary of the Pull Request

> ## Abstract
> 
> Multiple related scenarios have come up where it would be beneficial
to display
> actionable UI to the user within the context of the active terminal
itself. This
> UI would be akin to the Intellisense UI in Visual Studio. It appears
right where
> the user is typing, and can help provide immediate content for the
user, based
> on some context. The "Suggestions UI" is this new ephemeral UI within
the
> Windows Terminal that can display different types of actions, from
different
> sources.
> 


## Detailed Description of the Pull Request / Additional comments

_\*<sup>\*</sup><sub>\*</sub> read the spec
<sub>\*</sub><sup>\*</sup>\*_

Similar to #14792, a lot of this code is written. This stuff isn't
checked in though, so I'm presenting formally before I start yeeting PRs
out there.

## PR Checklist
- [x] This is a spec for #1595. It also references:
  * #3121
  * #10436
  * #12927
  * #12863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A11yMAS Accessibility tracking Area-User Interface Issues pertaining to the user interface of the Console or Terminal Disability-All Accessibility tracking In-PR This issue has a related PR InclusionBacklog Accessibility tracking InclusionBacklog-Windows TerminalWin32 Accessibility tracking Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
Specification Tracker
  
Spec In Review ⏰
Development

Successfully merging a pull request may close this issue.

7 participants