github / gh-copilot

Ask for assistance right in your terminal.

Home Page:https://docs.github.com/en/copilot/github-copilot-in-the-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide support for PowerShell Desktop 5.x

andyfeller opened this issue · comments

Overview

This is a follow up to #38 regarding extending the gh copilot alias support for PowerShell to include PowerShell Desktop. As explained by @xt0rted below, the current design of the ghcs function takes advantage of features not backwards compatible with PowerShell 5.x:

Could you elaborate on why you might need that?

@andyfeller by using the clean block the aliases require powershell core 7.3+. Any version older than that, including the original windows only version, will give an error about missing closing }.

At C:\Users\brian\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:89 char:15
+ function ghcs {
+               ~
Missing closing '}' in statement block or type definition.
At C:\Users\brian\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:145 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
At C:\Users\brian\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:147 char:15
+ function ghce {
+               ~
Missing closing '}' in statement block or type definition.
At C:\Users\brian\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:169 char:1
+ }

+ ~

Unexpected token '}' in expression or statement.

    + CategoryInfo          : ParserError: (:) [], ParseException

    + FullyQualifiedErrorId : MissingEndCurlyBrace

powershell.exe is the old version and is 5.1 on my machine, while pwsh.exe is the newer cross platform version.

Originally posted by @xt0rted in #38

It may be helpful adding that this is only supported by powershell 7+, as by default terminal in windows 11 uses powershell 5.