Skip to content

Instantly share code, notes, and snippets.

@iNViTiON
Created April 14, 2023 05:09
Show Gist options
  • Save iNViTiON/79de817bd17cb206584d8748187d34e9 to your computer and use it in GitHub Desktop.
Save iNViTiON/79de817bd17cb206584d8748187d34e9 to your computer and use it in GitHub Desktop.
Setup GitHub Copilot CLI alias for PowerShell
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
@iNViTiON
Copy link
Author

Gist upload with GitHub Copilot CLI.
The first try is with --name filename that's incorrect and needs to be revised.
image

@LeQuyetTien
Copy link

Great! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment