microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.94k stars 8.35k forks source link

Feature Request - Scripts Panel #1595

Closed nick22985 closed 1 year ago

nick22985 commented 5 years ago

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

JushBJJ commented 5 years ago

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

JushBJJ commented 5 years ago

1000

zadjii-msft commented 5 years ago

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

zadjii-msft commented 3 years ago

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](https://user-images.githubusercontent.com/18356694/78796811-75f33480-797c-11ea-8811-aad5c7671206.png) You can check it out over at [zadjii/keep](https://github.com/zadjii/keep). Admittedly, I only update it when I feel the itch, and it only works for CMD, but it works for me ¯\\\_(ツ)_/¯ 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: * [Scenario: Add support for 3rd-party extensions #4000](https://github.com/microsoft/terminal/issues/4000) - to support extensions at all * [Feature Request: Command Palette #2046](https://github.com/microsoft/terminal/issues/2046) - to provide a UI for running these commands easily * #I-cant-remember-which - to use a `ShortcutAction` to send input to the attached commandline app 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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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:

swiffer commented 1 year ago

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!