Skip to content

Instantly share code, notes, and snippets.

@hermanussen
Last active November 21, 2023 09:41
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 hermanussen/36d72f4d216b2caa9ca699aa98cf44b9 to your computer and use it in GitHub Desktop.
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
# Example usage:
#
# > ?? list all .csv files in the current folder without file extension
#
# Suggestion:
# Get-ChildItem -Filter *.csv | foreach { $_.BaseName }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment