17.1 C
New York
Sunday, November 17, 2024

GitHub Copilot for CLI for PowerShell



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

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

This is cool and all, but I use PowerShell. It turns out that these? The commands are just router commands for a larger EXE called github-copilot-cli. So if you say “?? something”, you’re actually saying “github-copilot-cli, what-the-hell”.

So this means I should be able to make the same or similar aliases for my PowerShell message AND change the injected message (look at me, I’m a message engineer) to add ‘use powershell to’.

Now, it’s not perfect, but hopefully it makes it clear to the Copilot CLI team that PowerShell needs love too.

Here are my aliases. Feel free to suggest if these suck. Note adding “powershell user to” for ?? one. Can I make a? and ap? where one does bash and the other does PowerShell. You could also have it use wsl.exe and pay for bash. Many 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 then also offers to run the command. Very soft.

I hope you like it. Lots of fun things happen in this space.




About Scott

Scott Hanselman is a former professor, former chief financial architect, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed comedian, a pigtailer and a book author.

Facebook
twitter
subscribe
About Fact sheet

Accommodation by
Hosted on an Azure App Service










Related Articles

Latest Articles