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

Command Snippet #6412

Closed
leopripos opened this issue Jun 8, 2020 · 9 comments
Closed

Command Snippet #6412

leopripos opened this issue Jun 8, 2020 · 9 comments
Labels
Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Issue-Question For questions or discussion Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-External For issues that are outside this codebase

Comments

@leopripos
Copy link

Description of the new feature/enhancement

Create command snippets like IDE snippets. Users can type something and then press tab to complete automatically. This is basically very simmilar with directory / file auto complete.

This will be very useful for long commands.

Proposed technical implementation details (optional)

User can configure their snippet in settings.json, for ex:

{
  "snippets" : [
      {
        "snippet": "cd-project-x",
        "command": "cd  D:\Projects\Project-X\"
      },
      {
        "snippet": "dn-build-xxx",
        "command": "dotnet build D:\Projects\Project-X\ --param1 --param2 --param3"
      }
  ]
}
@leopripos leopripos added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 8, 2020
@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 8, 2020
@WSLUser
Copy link
Contributor

WSLUser commented Jun 9, 2020

From CLI perspective, there is PSReadline and bash_completions, and other shell related autocompletion software. From settings perpective, there's already a json schema that's added that VSCode will intelligently recognize and provide suggestions for. It even recently added trailing comma support.

@zadjii-msft
Copy link
Member

So, this is probably something that would be best served by whatever commandline app you're using. As @WSLUser mentioned, you can (probably) configure PSReadline to do something like this for powershell, bash_completions for bash, and I'm sure zsh, fish, etc all have their own variants.

If your preferred shell is cmd.exe, you're probably out of luck :/

<shameless self plug>
Though, my preferred shell is cmd, so I wrote #keep as a utility for doing exactly the two things you've called out above: going to a directory, and doing something in that directory:

image

The docs aren't great, and it hasn't been updated in a while (but that's because I don't really think it needs to be), but that might scratch your itch.

</shameless self plug>

@zadjii-msft zadjii-msft added Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Issue-Question For questions or discussion Resolution-External For issues that are outside this codebase labels Jun 9, 2020
@WSLUser
Copy link
Contributor

WSLUser commented Jun 9, 2020

I believe Click was created for similar in cmd but the latest version is not stable and is abandoned. If you're not using in cmder though, it will be fine.

@rmansnacks
Copy link

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.

@pem884
Copy link

pem884 commented Nov 9, 2021

I agree with @rmansnacks - have heard of one or two peers using "Ditto" clipboard manager for storing snippets in kind of a global way. I wouldn't be sure if there are any drawbacks to it, but wanted to comment in case anyone, like me, comes back here looking for "Windows Terminal Snippets". Hope this helps someone.

@WSLUser

This comment has been minimized.

@zadjii-msft
Copy link
Member

We're also more general-purpose tracking this in #1595, so go toss your 👍 on that thread ☺️

@zadjii-msft
Copy link
Member

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.

@pem884
Copy link

pem884 commented Nov 11, 2021

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.

Hey, that's brilliant - I'm excited to give it a try. Thanks so much, @zadjii-msft !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Issue-Question For questions or discussion Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-External For issues that are outside this codebase
Projects
None yet
Development

No branches or pull requests

5 participants