This repository was archived by the owner on Oct 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
This repository was archived by the owner on Oct 30, 2025. It is now read-only.
[BUG]: PowerShell aliases give an unknown command error #38
Copy link
Copy link
Closed as not planned
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
I just installed this extension and then ran gh copilot alias for powershell. The resulting output calls gh copilot.exe which doesn't run, but if I remove the .exe part it works just fine.
Versions
gh --version: 2.46.0
gh copilot --version: 1.0.0
$psversiontable: 7.4.1
Relevant terminal output
Setup log
❯ gh copilot alias
? Which shell to generate aliases for?
> PowerShell
function ghcs {
# Debug support provided by common PowerShell function parameters, which is natively aliased as -d or -db
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4#-debug
param(
[ValidateSet('gh', 'git', 'shell')]
[Alias('t')]
[String]$Target = 'shell',
[Parameter(Position=0, ValueFromRemainingArguments)]
[string]$Prompt
)
begin {
# Create temporary file to store potential command user wants to execute when exiting
$executeCommandFile = New-TemporaryFile
# Store original value of GH_DEBUG environment variable
$envGhDebug = $Env:GH_DEBUG
}
process {
if ($PSBoundParameters['Debug']) {
$Env:GH_DEBUG = 'api'
}
gh copilot.exe suggest -t $Target -s "$executeCommandFile" $Prompt
}
end {
# Execute command contained within temporary file if it is not empty
if ($executeCommandFile.Length -gt 0) {
# Extract command to execute from temporary file
$executeCommand = (Get-Content -Path $executeCommandFile -Raw).Trim()
# Insert command into PowerShell up/down arrow key history
[Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($executeCommand)
# Insert command into PowerShell history
$now = Get-Date
$executeCommandHistoryItem = [PSCustomObject]@{
CommandLine = $executeCommand
ExecutionStatus = [Management.Automation.Runspaces.PipelineState]::NotStarted
StartExecutionTime = $now
EndExecutionTime = $now.AddSeconds(1)
}
Add-History -InputObject $executeCommandHistoryItem
# Execute command
Write-Host "`n"
Invoke-Expression $executeCommand
}
}
clean {
# Clean up temporary file used to store potential command user wants to execute when exiting
Remove-Item -Path $executeCommandFile
# Restore GH_DEBUG environment variable to its original value
$Env:GH_DEBUG = $envGhDebug
}
}
function ghce {
# Debug support provided by common PowerShell function parameters, which is natively aliased as -d or -db
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4#-debug
param(
[Parameter(Position=0, ValueFromRemainingArguments)]
[string[]]$Prompt
)
begin {
# Store original value of GH_DEBUG environment variable
$envGhDebug = $Env:GH_DEBUG
}
process {
if ($PSBoundParameters['Debug']) {
$Env:GH_DEBUG = 'api'
}
gh copilot.exe explain $Prompt
}
clean {
# Restore GH_DEBUG environment variable to its original value
$Env:GH_DEBUG = $envGhDebug
}
}ghcs test
unknown command "copilot.exe" for "gh"rlove, masewo and philfontaine
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working