# GitHub Copilot for CLI for PowerShell

DevFeed: [GitHub Copilot for CLI for PowerShell](<https://devfeed.tech/articles/github-copilot-for-cli-for-powershell-21853.md>)

Original publisher: [Read original article](<https://www.hanselman.com/blog/github-copilot-for-cli-for-powershell>)

Author: Scott Hanselman

Published: 2023-04-25T15:31:49Z

Content type: tutorial

Language: en

Sources: [Scott Hanselman](<https://devfeed.tech/sources/scott-hanselman.md>)

Topics: [GitHub Copilot CLI](<https://devfeed.tech/topics/github-copilot-cli.md>), [PowerShell](<https://devfeed.tech/topics/powershell.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [GitHub](<https://devfeed.tech/topics/github.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [github](<https://devfeed.tech/tags/github.md>), [github-copilot-cli](<https://devfeed.tech/tags/github-copilot-cli.md>), [powershell](<https://devfeed.tech/tags/powershell.md>)

## AI overview

This article explains how GitHub Copilot CLI routes its shell commands through the github-copilot-cli executable and demonstrates PowerShell aliases that adapt those commands for PowerShell, including an option to run the generated command.

## Source excerpt

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.