GitHub Copilot for CLI for PowerShell



GitHub Subsequent has this cool mission that’s principally Copilot for the CLI (command line interface). You’ll be able to join their waitlist on the Copilot for CLI web site.

Copilot for CLI offers three shell instructions: ??, git? and gh?

That is cool and all, however I exploit PowerShell. Seems these ?? instructions are simply router instructions to a bigger EXE known as github-copilot-cli. So if you happen to go “?? one thing” you are actually going “github-copilot-cli what-the-shell one thing.”

So this implies I ought to be capable to to do the identical/related aliases for my PowerShell immediate AND change the injected immediate (take a look at me I am a immediate engineer) so as to add ‘use powershell to.’

Now it isn’t good, however hopefully it would make the purpose to the Copilot CLI crew that PowerShell wants love additionally.

Listed here are my aliases. Be at liberty to recommend if these suck. Notice the addition of “consumer powershell to” for the ?? one. I could make a ?? and a p? the place one does bash and one does PowerShell. I might even have it use wsl.exe and shell out to bash. Numerous potentialities.

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

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

It additionally then gives to run the command. Very easy.

image

Hope you prefer it. Numerous enjoyable stuff occurring on this house.




About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, advisor, father, diabetic, and Microsoft worker. He’s a failed stand-up comedian, a cornrower, and a e book writer.

facebook
twitter
subscribe
About   Publication

Internet hosting By
Hosted in an Azure App Service










Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles