Last active
November 21, 2023 09:41
-
-
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.
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 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