GitHub Copilot for CLI for PowerShell 您所在的位置:网站首页 systemiofile GitHub Copilot for CLI for PowerShell

GitHub Copilot for CLI for PowerShell

2023-05-07 04:28| 来源: 网络整理| 查看: 265

Sponsored By

GitHub Next has this cool project that is basically Copilot for the CLI (command line interface). You can sign up for their waitlist at the Copilot for CLI site.

Copilot for CLI provides three shell commands: ??, git? and gh?

This is cool and all, but I use PowerShell. Turns out these ?? commands are just router commands to a larger EXE called github-copilot-cli. So if you go "?? something" you're really going "github-copilot-cli what-the-shell something."

So this means I should be able to to do the same/similar aliases for my PowerShell prompt AND change the injected prompt (look at me I'm a prompt engineer) to add 'use powershell to.'

Now it's not perfect, but hopefully it will make the point to the Copilot CLI team that PowerShell needs love also.

Here are my aliases. Feel free to suggest if these suck. Note the addition of "user powershell to" for the ?? one. I may make a ?? and a p? where one does bash and one does PowerShell. I could also have it use wsl.exe and shell out to bash. Lots of possibilities.

function ?? { $TmpFile = New-TemporaryFile github-copilot-cli what-the-shell ('use powershell to ' + $args) --shellout $TmpFile if ([System.IO.File]::Exists($TmpFile)) { $TmpFileContents = Get-Content $TmpFile if ($TmpFileContents -ne $nill) { Invoke-Expression $TmpFileContents Remove-Item $TmpFile } }}

function git? { $TmpFile = New-TemporaryFile github-copilot-cli git-assist $args --shellout $TmpFile if ([System.IO.File]::Exists($TmpFile)) { $TmpFileContents = Get-Content $TmpFile if ($TmpFileContents -ne $nill) { Invoke-Expression $TmpFileContents Remove-Item $TmpFile } }}function gh? { $TmpFile = New-TemporaryFile github-copilot-cli gh-assist $args --shellout $TmpFile if ([System.IO.File]::Exists($TmpFile)) { $TmpFileContents = Get-Content $TmpFile if ($TmpFileContents -ne $nill) { Invoke-Expression $TmpFileContents Remove-Item $TmpFile } }}

It also then offers to run the command. Very smooth.

image

Hope you like it. Lots of fun stuff happening in this space.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe About   Newsletter Hosting By Hosted in an Azure App Service Comment on this post [6] Share on Twitter or Facebook or use the Permalink


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有