Skip to content

Instantly share code, notes, and snippets.

@ArjixWasTaken
Last active April 14, 2023 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArjixWasTaken/b32ae11c2188704909d224549a6d4eea to your computer and use it in GitHub Desktop.
Save ArjixWasTaken/b32ae11c2188704909d224549a6d4eea to your computer and use it in GitHub Desktop.
CopilotX CLI alias for powershell
function ??() {
$TMPFILE = Get-ChildItem (New-TemporaryFile) | Rename-Item -NewName { [IO.Path]::ChangeExtension($_, ".ps1") } -PassThru
github-copilot-cli what-the-shell "$args (for powershell, don't use powershell aliases, eg ls => Get-ChildItem)" --shellout $TMPFILE.FullName
if (Test-Path $TMPFILE.FullName) {
Invoke-Expression $TMPFILE | Write-Output;
} else {
Write-Output "Apologies! Extracting command failed";
}
Remove-Item -Path $TMPFILE -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment