We are, for now, just using the official github copilot CLI, but they didn't really have hooks for PowerShell, so I wrote a few functions to implement it.
It works great, as you can see:
We are, for now, just using the official github copilot CLI, but they didn't really have hooks for PowerShell, so I wrote a few functions to implement it.
It works great, as you can see:
| function NewTemporaryScript { | |
| [IO.Path]::ChangeExtension(([IO.Path]::GetTempPath() + [IO.Path]::GetRandomFileName()), "ps1") | |
| } | |
| function InvokeTemporaryScript { | |
| [CmdletBinding()] | |
| param($ScriptPath) | |
| if (Test-Path $ScriptPath) { | |
| . $ScriptPath | |
| Remove-Item $ScriptPath | |
| } | |
| } | |
| function Request-CopilotAssist { | |
| [CmdletBinding()] | |
| [Alias('??','rqa')] | |
| param([Parameter(ValueFromRemainingArguments)][string[]]$args) | |
| $TmpFile = NewTemporaryScript | |
| github-copilot-cli what-the-shell ('use powershell to ' + $args) --shellout $TmpFile | |
| InvokeTemporaryScript $TmpFile | |
| } | |
| function Request-CopilotGitAssist { | |
| [CmdletBinding()] | |
| [Alias('git?','rqga')] | |
| param([Parameter(ValueFromRemainingArguments)][string[]]$args) | |
| $TmpFile = NewTemporaryScript | |
| github-copilot-cli git-assist $args --shellout $TmpFile | |
| InvokeTemporaryScript $TmpFile | |
| } | |
| function Request-CopilotGitHubAssist { | |
| [CmdletBinding()] | |
| [Alias('gh?','rqgha')] | |
| param([Parameter(ValueFromRemainingArguments)][string[]]$args) | |
| $TmpFile = NewTemporaryScript | |
| github-copilot-cli gh-assist $args --shellout $TmpFile | |
| InvokeTemporaryScript $TmpFile | |
| } | |
| Export-ModuleMember -Function *-* -Alias * |