Created
April 14, 2023 05:09
-
-
Save iNViTiON/79de817bd17cb206584d8748187d34e9 to your computer and use it in GitHub Desktop.
Setup GitHub Copilot CLI alias for PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function copilot_check-response { | |
if ( $Args[0] -eq $true ) { | |
$FIXED_CMD = Get-Content $TMPFILE | |
Remove-Item $TMPFILE -ErrorAction SilentlyContinue | |
Invoke-Expression $FIXED_CMD | |
} | |
else { | |
Write-Host "User cancelled the command." | |
Remove-Item $TMPFILE -ErrorAction SilentlyContinue | |
} | |
} | |
Function copilot_what-the-shell { | |
$TMPFILE = New-TemporaryFile | |
trap {Remove-Item $TMPFILE -ErrorAction SilentlyContinue} | |
github-copilot-cli what-the-shell "$args" --shellout $TMPFILE | |
copilot_check-response $? | |
} | |
Set-Alias ?? copilot_what-the-shell | |
Function copilot_git-assist { | |
$TMPFILE = New-TemporaryFile | |
trap {Remove-Item $TMPFILE -ErrorAction SilentlyContinue} | |
github-copilot-cli git-assist "$args" --shellout $TMPFILE | |
copilot_check-response $? | |
} | |
Set-Alias git? copilot_git-assist | |
Function copilot_gh-assist { | |
$TMPFILE = New-TemporaryFile | |
trap {Remove-Item $TMPFILE -ErrorAction SilentlyContinue} | |
github-copilot-cli gh-assist "$args" --shellout $TMPFILE | |
copilot_check-response $? | |
} | |
Set-Alias gh? copilot_gh-assist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! Thank you.