microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.52k stars 28.1k forks source link

add aliases support to shell integration #210983

Open cpendery opened 2 months ago

cpendery commented 2 months ago

I'd like if vscode's shell integration allowed injecting command aliases from the settings.json file. It would be really helpful to allow projects with a range of shells/os's to share a common set of commands

Settings.json

{
  "terminal.integrated.shellIntegration.aliases":  {
    "gp": "git push"
  }
}

Pwsh Injected Command

function __VSCode-<aliasName>() {
  <aliasCommand> $args
}
Set-Alias -Name '<aliasName>' -Value '__VSCode-<aliasName>'

Bash/Fish/Zsh Injected Command

alias <aliasName>='<aliasCommand>'
Tyriar commented 2 months ago

I'm not that keen on the idea of us injecting this stuff for set up native shell aliases. However, this is very close to the run recent command pin feature:

image

As well as the snippets idea I've had for a while; essentially aliases that show up in the suggest widget which would work similarly to snippets in the editor:

image image

This is something I had in mind as particularly useful for copilot chat suggestions.

cpendery commented 2 months ago

Sounds good, snippets are a cool idea!

mitsukuri commented 2 weeks ago

Having per-project aliases would be awesome! This way we could avoid littering our repositories with scripts that must be locally gitignored, and polluting our global aliases via system-wide shell configuration.

Upvoting this feature request.