GitHub Copilot for CLI for PowerShell
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.
Hope you like it. Lots of fun stuff happening in this space.© 2025 Scott Hanselman. All rights reserved.     
---
GitHub Copilot for CLI for PowerShell
April 25, 2023
Comment on this post [6]
Posted in AI | PowerShell
-->
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: 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.
[Image: facebook]
[Image: bluesky]
[Image: subscribe]
Hosting By
[Image: Hosted on Linux using .NET in an Azure App Service]
Comment on this post [6]
Permalink and post anywhere!
April 25, 2023 12:13
Cool stuff, just signed up for the waitlist. I'm already a CoPilot paid subscriber, would be interesting to try it out in CLI
Ricard Torres
April 26, 2023 2:34
Copilot is already available from the PowershellAI module. And it is real fun. At least it asks for a confirmation before executing the command. Is this a different one?
Ferose Khan J
April 26, 2023 5:21
When copilot suggests more than one line / two commands, the Invoke-Expression throws that it cannot convert an System.Object[] to a 'System.String' required by paramater 'Command'.
Any idea how to resolve that?
Sebastian Gingter
April 26, 2023 6:11
While you wait, ai-shell by @builder-io is a fantastic command line helper that generates shell commands from natural language: “find all .git folders created in the last week and write them to newprojects.txt”
https://github.com/BuilderIO/ai-shell
James White
April 26, 2023 11:33
Instead of invoking the expression, you should use the PSReadline API to inject the returned code into the input buffer. I had planned on writing something that used GPT4 API to do this but since you're already on it and I have a disgusting pool to clear up... 😁
Josh Einstein
April 28, 2023 6:52
While Copilot and derivatives can be handy, it is basically in the same sense, as stolen car also is handy. Microsoft can go away with this only because of its size and resources, but it does not change the fact the Copilot is based on stolen data (which it is even amusing a bit, they could target companies to steal software from, but they chose only open-source projects -- likelihood of being sued by freelancer is much less than being sued by some company). "MS loves open-source" has new meaning :-).
macias
---
[Original source](http://feeds.hanselman.com/~/737271731/0/scotthanselman~GitHub-Copilot-for-CLI-for-PowerShell)