Use Copilot to suggest commands when using Powershell.
This is a project just for fun, don't take it seriously🤣
- Powershell 7.2+ with PSReadLine module installed (usually by default).
- A valid Copilot subscription.
- Build the project.
- Open Powershell in Windows Terminal.
Import-Module {path to PSCopilot.dll}
. Request-Copilot
, and finish the verification.- Now you can use PSCopilot. Press F2 repeatedly to get suggestions.
You can use this pattern to suggest Copilot:
echo "shutdown the computer in 60s";
(now Press F2)
(Maybe Write-Output
is better than echo
.)
(Optional) You can also copy all files to $PSHOME\Modules\PSCopilot
and use Import-Module PSCopilot
to launch PSCopilot.
- Build the project with
Debug
configuration. - Open Powershell in Windows Terminal.
Import-Module {path to PSCopilot.dll}
. Set-Copilot -dbg
. Debugger Attach dialog will pop up.
This project is using copilotplayground/CopilotDev.NET (license: MIT). Much thanks to the author TheFortification.
PSReadLine Predictor mechanism does not support async suggestion. We have to return suggestions immediately. When you input or press F2, a query will be send to Copilot. The returned suggestion will be kept, and will be displayed when you press F2 again.
Yes, it is silly🤡
To clear input history, use both Alt + F7 and Clear-Copilot
command.
by Ulysses (wdwxy12345{at}gmail.com)