Skip to content

Instantly share code, notes, and snippets.

@hermanussen
Last active July 17, 2024 07:10
Show Gist options
  • Select an option

  • Save hermanussen/36d72f4d216b2caa9ca699aa98cf44b9 to your computer and use it in GitHub Desktop.

Select an option

Save hermanussen/36d72f4d216b2caa9ca699aa98cf44b9 to your computer and use it in GitHub Desktop.
Get GitHub Copilot for CLI in Powershell by adding the contents here to your $Profile. Ensure that you have installed and authenticated in the GitHub CLI to make it work properly.
Function GhCopilotSuggestShell {
gh copilot suggest -t shell "$args"
}
Function GhCopilotSuggestPowerShell {
gh copilot suggest -t shell "$args using Windows Powershell"
}
Function GhCopilotSuggestPowerShellCore {
gh copilot suggest -t shell "$args using Powershell Core (pswh)"
}
Function GhCopilotSuggestGit {
gh copilot suggest -t git "$args"
}
Function GhCopilotSuggestGitHub {
gh copilot suggest -t gh "$args"
}
# By default use Powershell Core
Set-Alias ?? GhCopilotSuggestPowerShellCore
# Explicit calls for Powershell related stuff
Set-Alias pwsh? GhCopilotSuggestPowerShellCore
Set-Alias powershell? GhCopilotSuggestPowerShell
# Regular supported Copilot targets ("gh copilot suggest --help" for more info)
Set-Alias shell? GhCopilotSuggestShell
Set-Alias git? GhCopilotSuggestGit
Set-Alias gh? GhCopilotSuggestGitHub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment